| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
/**
- * Various predefined settings that have been migrated to the setting table
+ * Various predefined settings that have been migrated to the setting table.
*/
const
ADDRESS_STANDARDIZATION_PREFERENCES_NAME = 'Address Standardization Preferences',
* @param int $domainID
* @param bool $force
*
- * @return boolean
+ * @return bool
* true if item is already in cache
- * @static
*/
- static function inCache(
+ public static function inCache(
$group,
$name,
$componentID = NULL,
}
/**
- * Allow key o be cleared
+ * Allow key o be cleared.
* @param string $cacheKey
*/
public static function flushCache($cacheKey) {
*
* @return string
*/
- static function setCache(
+ public static function setCache(
$values,
$group,
$componentID = NULL,
*
* @return CRM_Core_DAO_Domain|CRM_Core_DAO_Setting
*/
- static function dao(
+ public static function dao(
$group,
$name = NULL,
$componentID = NULL,
}
/**
- * Retrieve the value of a setting from the DB table
+ * Retrieve the value of a setting from the DB table.
*
* @param string $group
* (required) The group name of the item.
*
* @return mixed
* The data if present in the setting table, else null
- * @static
*/
- static function getItem(
+ public static function getItem(
$group,
$name = NULL,
$componentID = NULL,
}
/**
- * Store multiple items in the setting table
+ * Store multiple items in the setting table.
*
* @param array $params
* (required) An api formatted array of keys and values.
- * @param null $domains
+ * @param array $domains Array of domains to get settings for. Default is the current domain
* @param $settingsToReturn
*
- * @domains array an array of domains to get settings for. Default is the current domain
- * @return void
- * @static
+ * @return array
*/
public static function getItems(&$params, $domains = NULL, $settingsToReturn) {
$originalDomain = CRM_Core_Config::domainID();
}
}
else {
- $setting =
- CRM_Core_BAO_Setting::getItem(
- $fields['values'][$name]['group_name'],
- $name,
- CRM_Utils_Array::value('component_id', $params),
- NULL,
- CRM_Utils_Array::value('contact_id', $params),
- $domainID
- );
+ $setting = CRM_Core_BAO_Setting::getItem(
+ $fields['values'][$name]['group_name'],
+ $name,
+ CRM_Utils_Array::value('component_id', $params),
+ NULL,
+ CRM_Utils_Array::value('contact_id', $params),
+ $domainID
+ );
}
if (!is_null($setting)) {
// we won't return if not set - helps in return all scenario - otherwise we can't indentify the missing ones
}
/**
- * Store an item in the setting table
+ * Store an item in the setting table.
*
* _setItem() is the common logic shared by setItem() and setItems().
*
* @param int $domainID
*
* @return void
- * @static
*/
- static function setItem(
+ public static function setItem(
$value,
$group,
$name,
}
/**
- * Store an item in a setting table
+ * Store an item in a setting table.
*
* _setItem() is the common logic shared by setItem() and setItems().
*
* @param int $createdID
* @param int $domainID
*/
- static function _setItem(
+ public static function _setItem(
$metadata,
$value,
$group,
if (isset($metadata['on_change'])) {
foreach ($metadata['on_change'] as $callback) {
- call_user_func($callback, unserialize($dao->value), $value, $metadata);
+ call_user_func(
+ Civi\Core\Resolver::singleton()->get($callback),
+ unserialize($dao->value),
+ $value,
+ $metadata
+ );
}
}
* @throws api_Exception
* @domains array an array of domains to get settings for. Default is the current domain
* @return array
- * @static
*/
public static function setItems(&$params, $domains = NULL) {
$originalDomain = CRM_Core_Config::domainID();
return TRUE;
}
else {
- list($class, $fn) = explode('::', $fieldSpec['validate_callback']);
- if (!$class::$fn($value, $fieldSpec)) {
+ $cb = Civi\Core\Resolver::singleton()->get($fieldSpec['validate_callback']);
+ if (!call_user_func_array($cb, array(&$value, $fieldSpec))) {
throw new api_Exception("validation failed for {$fieldSpec['name']} = $value based on callback {$fieldSpec['validate_callback']}");
}
}
*
* @return array
* the following information as appropriate for each setting
- * - name
- * - type
- * - default
- * - add (CiviCRM version added)
- * - is_domain
- * - is_contact
- * - description
- * - help_text
+ * - name
+ * - type
+ * - default
+ * - add (CiviCRM version added)
+ * - is_domain
+ * - is_contact
+ * - description
+ * - help_text
*/
- static function getSettingSpecification(
+ public static function getSettingSpecification(
$componentID = NULL,
$filters = array(),
$domainID = NULL,
}
/**
- * Load the settings files defined in a series of folders
+ * Load the settings files defined in a series of folders.
* @param array $metaDataFolders
* List of folder paths.
* @return array
}
/**
- * Load up settings metadata from files
+ * Load up settings metadata from files.
*/
public static function loadSettingsMetadata($metaDataFolder) {
$settingMetaData = array();
}
/**
- * Look for any missing settings and convert them from config or load default as appropriate
+ * Look for any missing settings and convert them from config or load default as appropriate.
* This should be run from GenCode & also from upgrades to add any new defaults.
*
* Multisites have often been overlooked in upgrade scripts so can be expected to be missing
*
* @return array
*/
- static function valueOptions(
+ public static function valueOptions(
$group,
$name,
$system = TRUE,
* @param int $userID
* @param string $keyField
*/
- static function setValueOption(
+ public static function setValueOption(
$group,
$name,
$value,
/**
* Civicrm_setting didn't exist before 4.1.alpha1 and this function helps taking decisions during upgrade
*
- * @return boolean
+ * @return bool
*/
public static function isUpgradeFromPreFourOneAlpha1() {
if (CRM_Core_Config::isUpgradeMode()) {
}
return FALSE;
}
+
}