本文整理汇总了PHP中CRM_Utils_Hook::alterSettingsFolders方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Hook::alterSettingsFolders方法的具体用法?PHP CRM_Utils_Hook::alterSettingsFolders怎么用?PHP CRM_Utils_Hook::alterSettingsFolders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Hook
的用法示例。
在下文中一共展示了CRM_Utils_Hook::alterSettingsFolders方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMetadata
/**
* WARNING: This interface may change.
*
* This provides information about the setting - similar to the fields concept for DAO information.
* As the setting is serialized code creating validation setting input needs to know the data type
* This also helps move information out of the form layer into the data layer where people can interact with
* it via the API or other mechanisms. In order to keep this consistent it is important the form layer
* also leverages it.
*
* Note that this function should never be called when using the runtime getvalue function. Caching works
* around the expectation it will be called during setting administration
*
* Function is intended for configuration rather than runtime access to settings
*
* The following params will filter the result. If none are passed all settings will be returns
*
* @param array $filters
* @param int $domainID
*
* @return array
* the following information as appropriate for each setting
* - name
* - type
* - default
* - add (CiviCRM version added)
* - is_domain
* - is_contact
* - description
* - help_text
*/
public static function getMetadata($filters = array(), $domainID = NULL)
{
if ($domainID === NULL) {
$domainID = \CRM_Core_Config::domainID();
}
$cache = \Civi::cache('settings');
$cacheString = 'settingsMetadata_' . $domainID . '_';
// the caching into 'All' seems to be a duplicate of caching to
// settingsMetadata__ - I think the reason was to cache all settings as defined & then those altered by a hook
$settingsMetadata = $cache->get($cacheString);
$cached = is_array($settingsMetadata);
if (!$cached) {
$settingsMetadata = $cache->get(self::ALL);
if (empty($settingsMetadata)) {
global $civicrm_root;
$metaDataFolders = array($civicrm_root . '/settings');
\CRM_Utils_Hook::alterSettingsFolders($metaDataFolders);
$settingsMetadata = self::loadSettingsMetaDataFolders($metaDataFolders);
$cache->set(self::ALL, $settingsMetadata);
}
}
\CRM_Utils_Hook::alterSettingsMetaData($settingsMetadata, $domainID, NULL);
if (!$cached) {
$cache->set($cacheString, $settingsMetadata);
}
self::_filterSettingsSpecification($filters, $settingsMetadata);
return $settingsMetadata;
}
示例2: getSettingSpecification
/**
* This provides information about the setting - similar to the fields concept for DAO information.
* As the setting is serialized code creating validation setting input needs to know the data type
* This also helps move information out of the form layer into the data layer where people can interact with
* it via the API or other mechanisms. In order to keep this consistent it is important the form layer
* also leverages it.
*
* Note that this function should never be called when using the runtime getvalue function. Caching works
* around the expectation it will be called during setting administration
*
* Function is intended for configuration rather than runtime access to settings
*
* The following params will filter the result. If none are passed all settings will be returns
*
* @param int $componentID
* Id of relevant component.
* @param array $filters
* @param int $domainID
* @param null $profile
*
* @return array
* the following information as appropriate for each setting
* - name
* - type
* - default
* - add (CiviCRM version added)
* - is_domain
* - is_contact
* - description
* - help_text
*/
public static function getSettingSpecification($componentID = NULL, $filters = array(), $domainID = NULL, $profile = NULL)
{
$cacheString = 'settingsMetadata_' . $domainID . '_' . $profile;
foreach ($filters as $filterField => $filterString) {
$cacheString .= "_{$filterField}_{$filterString}";
}
$cached = 1;
// the caching into 'All' seems to be a duplicate of caching to
// settingsMetadata__ - I think the reason was to cache all settings as defined & then those altered by a hook
$settingsMetadata = CRM_Core_BAO_Cache::getItem('CiviCRM setting Specs', $cacheString, $componentID);
if ($settingsMetadata === NULL) {
$settingsMetadata = CRM_Core_BAO_Cache::getItem('CiviCRM setting Spec', 'All', $componentID);
if (empty($settingsMetadata)) {
global $civicrm_root;
$metaDataFolders = array($civicrm_root . '/settings');
CRM_Utils_Hook::alterSettingsFolders($metaDataFolders);
$settingsMetadata = self::loadSettingsMetaDataFolders($metaDataFolders);
CRM_Core_BAO_Cache::setItem($settingsMetadata, 'CiviCRM setting Spec', 'All', $componentID);
}
$cached = 0;
}
CRM_Utils_Hook::alterSettingsMetaData($settingsMetadata, $domainID, $profile);
self::_filterSettingsSpecification($filters, $settingsMetadata);
if (!$cached) {
// this is a bit 'heavy' if you are using hooks but this function
// is expected to only be called during setting administration
// it should not be called by 'getvalue' or 'getitem
CRM_Core_BAO_Cache::setItem($settingsMetadata, 'CiviCRM setting Specs', $cacheString, $componentID);
}
return $settingsMetadata;
}