本文整理汇总了PHP中CRM_Core_Component::flushEnabledComponents方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Component::flushEnabledComponents方法的具体用法?PHP CRM_Core_Component::flushEnabledComponents怎么用?PHP CRM_Core_Component::flushEnabledComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Component
的用法示例。
在下文中一共展示了CRM_Core_Component::flushEnabledComponents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setComponentStatuses
/**
* Set components as enabled or disabled. Leave any other
* components unmodified.
*
* Note: This API has only been tested with CiviCRM 4.4.
*
* @param array $components keys are component names (e.g. "CiviMail"); values are booleans
*/
public function setComponentStatuses($components)
{
$getResult = civicrm_api3('setting', 'getsingle', array('domain_id' => CRM_Core_Config::domainID(), 'return' => array('enable_components')));
if (!is_array($getResult['enable_components'])) {
throw new CRM_Core_Exception("Failed to determine component statuses");
}
// Merge $components with existing list
$enableComponents = $getResult['enable_components'];
foreach ($components as $component => $status) {
if ($status) {
$enableComponents = array_merge($enableComponents, array($component));
} else {
$enableComponents = array_diff($enableComponents, array($component));
}
}
civicrm_api3('setting', 'create', array('domain_id' => CRM_Core_Config::domainID(), 'enable_components' => array_unique($enableComponents)));
CRM_Core_Component::flushEnabledComponents();
}