foreach ($domains as $domainID) {
$result[$domainID] = [];
foreach ($fieldsToGet as $name => $value) {
- $contactID = CRM_Utils_Array::value('contact_id', $params);
+ $contactID = $params['contact_id'] ?? NULL;
$setting = CRM_Core_BAO_Setting::getItem(NULL, $name, NULL, NULL, $contactID, $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
* (required) An api formatted array of keys and values.
* @param null $domains
*
- * @throws api_Exception
+ * @throws API_Exception
* @domains array an array of domains to get settings for. Default is the current domain
* @return array
*/
* Empty array to be populated with fields metadata.
* @param bool $createMode
*
- * @throws api_Exception
+ * @throws API_Exception
* @return array
* name => value array of the fields to be set (with extraneous removed)
*/
$fields = civicrm_api3('setting', 'getfields', $getFieldsParams);
$invalidParams = (array_diff_key($settingParams, $fields['values']));
if (!empty($invalidParams)) {
- throw new api_Exception(implode(',', array_keys($invalidParams)) . " not valid settings");
+ throw new API_Exception(implode(',', array_keys($invalidParams)) . " not valid settings");
}
if (!empty($settingParams)) {
$filteredFields = array_intersect_key($settingParams, $fields['values']);
* Metadata for given field (drawn from the xml)
*
* @return bool
- * @throws \api_Exception
+ * @throws \API_Exception
*/
public static function validateSetting(&$value, array $fieldSpec) {
+ // Deprecated guesswork - should use $fieldSpec['serialize']
if ($fieldSpec['type'] == 'String' && is_array($value)) {
$value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $value) . CRM_Core_DAO::VALUE_SEPARATOR;
}
else {
$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']}");
+ throw new API_Exception("validation failed for {$fieldSpec['name']} = $value based on callback {$fieldSpec['validate_callback']}");
}
}
}
* @param array $fieldSpec Metadata for given field (drawn from the xml)
*
* @return bool
- * @throws \api_Exception
+ * @throws \API_Exception
*/
public static function validateBoolSetting(&$value, $fieldSpec) {
if (!CRM_Utils_Rule::boolean($value)) {
- throw new api_Exception("Boolean value required for {$fieldSpec['name']}");
+ throw new API_Exception("Boolean value required for {$fieldSpec['name']}");
}
if (!$value) {
$value = 0;
public static function onChangeEnvironmentSetting($oldValue, $newValue, $metadata) {
if ($newValue != 'Production') {
$mailing = Civi::settings()->get('mailing_backend');
- if ($mailing['outBound_option'] != 2) {
+ if ($mailing['outBound_option'] != CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED) {
Civi::settings()->set('mailing_backend_store', $mailing);
}
Civi::settings()->set('mailing_backend', ['outBound_option' => CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED]);