Merge pull request #5179 from eileenmcnaughton/CRM-15798-master
[civicrm-core.git] / CRM / Core / BAO / Setting.php
index 7b064345a3092ba3c467791491c01f95210b234e..c42b444a9927b6e0d4187ab095d1228aa77b6831 100644 (file)
@@ -44,7 +44,7 @@
 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',
@@ -115,7 +115,7 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
   }
 
   /**
-   * Allow key o be cleared
+   * Allow key o be cleared.
    * @param string $cacheKey
    */
   public static function flushCache($cacheKey) {
@@ -201,7 +201,7 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
   }
 
   /**
-   * 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.
@@ -324,7 +324,7 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
   }
 
   /**
-   * Store an item in the setting table
+   * Store an item in the setting table.
    *
    * _setItem() is the common logic shared by setItem() and setItems().
    *
@@ -364,7 +364,7 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
   }
 
   /**
-   * Store an item in a setting table
+   * Store an item in a setting table.
    *
    * _setItem() is the common logic shared by setItem() and setItems().
    *
@@ -397,7 +397,12 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
 
     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
+        );
       }
     }
 
@@ -587,8 +592,8 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
       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']}");
       }
     }
@@ -689,7 +694,7 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
   }
 
   /**
-   * 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
@@ -708,7 +713,7 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
   }
 
   /**
-   * Load up settings metadata from files
+   * Load up settings metadata from files.
    */
   public static function loadSettingsMetadata($metaDataFolder) {
     $settingMetaData = array();