本文整理汇总了PHP中CRM_Core_BAO_Setting::_setItem方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Setting::_setItem方法的具体用法?PHP CRM_Core_BAO_Setting::_setItem怎么用?PHP CRM_Core_BAO_Setting::_setItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_Setting
的用法示例。
在下文中一共展示了CRM_Core_BAO_Setting::_setItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setItems
/**
* Store multiple items in the setting table. Note that this will also store config keys
* the storage is determined by the metdata and is affected by
* 'name' setting's name
* 'prefetch' = store in config
* 'config_only' = don't store in settings
* 'config_key' = the config key is different to the settings key - e.g. debug where there was a conflict
* 'legacy_key' = rename from config or setting with this name
*
* _setItem() is the common logic shared by setItem() and setItems().
*
* @param array $params
* (required) An api formatted array of keys and values.
* @param null $domains
*
* @throws api_Exception
* @domains array an array of domains to get settings for. Default is the current domain
* @return array
*/
public static function setItems(&$params, $domains = NULL)
{
$originalDomain = CRM_Core_Config::domainID();
if (empty($domains)) {
$domains[] = $originalDomain;
}
$reloadConfig = FALSE;
$fields = $config_keys = array();
$fieldsToSet = self::validateSettingsInput($params, $fields);
foreach ($fieldsToSet as $settingField => &$settingValue) {
self::validateSetting($settingValue, $fields['values'][$settingField]);
}
foreach ($domains as $domainID) {
if ($domainID != CRM_Core_Config::domainID()) {
$reloadConfig = TRUE;
CRM_Core_BAO_Domain::setDomain($domainID);
}
$result[$domainID] = array();
foreach ($fieldsToSet as $name => $value) {
if (empty($fields['values'][$name]['config_only'])) {
CRM_Core_BAO_Setting::_setItem($fields['values'][$name], $value, $fields['values'][$name]['group_name'], $name, CRM_Utils_Array::value('component_id', $params), CRM_Utils_Array::value('contact_id', $params), CRM_Utils_Array::value('created_id', $params), $domainID);
}
if (!empty($fields['values'][$name]['prefetch'])) {
if (!empty($fields['values'][$name]['config_key'])) {
$name = $fields['values'][$name]['config_key'];
}
$config_keys[$name] = $value;
}
$result[$domainID][$name] = $value;
}
if ($reloadConfig) {
CRM_Core_Config::singleton($reloadConfig, $reloadConfig);
}
if (!empty($config_keys)) {
CRM_Core_BAO_ConfigSetting::create($config_keys);
}
if ($reloadConfig) {
CRM_Core_BAO_Domain::resetDomain();
}
}
return $result;
}