diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php
index 8ded9f1b3e1c..d106c6f5cf89 100644
--- a/CRM/Activity/BAO/Activity.php
+++ b/CRM/Activity/BAO/Activity.php
@@ -2067,8 +2067,7 @@ public static function getProfileFields() {
'is_current_revision',
'activity_is_deleted',
];
- $config = CRM_Core_Config::singleton();
- if (!in_array('CiviCampaign', $config->enableComponents)) {
+ if (!CRM_Core_Component::isEnabled('CiviCampaign')) {
$skipFields[] = 'activity_engagement_level';
}
diff --git a/CRM/Activity/Task.php b/CRM/Activity/Task.php
index d1689bdb7fcc..c362893d572f 100644
--- a/CRM/Activity/Task.php
+++ b/CRM/Activity/Task.php
@@ -90,8 +90,7 @@ public static function tasks() {
],
];
- $config = CRM_Core_Config::singleton();
- if (in_array('CiviCase', $config->enableComponents)) {
+ if (CRM_Core_Component::isEnabled('CiviCase')) {
if (CRM_Core_Permission::check('access all cases and activities') ||
CRM_Core_Permission::check('access my cases and activities')
) {
diff --git a/CRM/Admin/Form/Options.php b/CRM/Admin/Form/Options.php
index 4afd0fbf706f..b5002a575e0a 100644
--- a/CRM/Admin/Form/Options.php
+++ b/CRM/Admin/Form/Options.php
@@ -269,8 +269,7 @@ public function buildQuickForm() {
// If CiviCase enabled AND "Add" mode OR "edit" mode for non-reserved activities, only allow user to pick Core or CiviCase component.
// FIXME: Each component should define whether adding new activity types is allowed.
- $config = CRM_Core_Config::singleton();
- if ($this->_gName == 'activity_type' && in_array("CiviCase", $config->enableComponents) &&
+ if ($this->_gName == 'activity_type' && CRM_Core_Component::isEnabled("CiviCase") &&
(($this->_action & CRM_Core_Action::ADD) || !$isReserved)
) {
$caseID = CRM_Core_Component::getComponentID('CiviCase');
diff --git a/CRM/Campaign/BAO/Campaign.php b/CRM/Campaign/BAO/Campaign.php
index c9808c5b070d..02fbacc0f485 100644
--- a/CRM/Campaign/BAO/Campaign.php
+++ b/CRM/Campaign/BAO/Campaign.php
@@ -294,7 +294,7 @@ public static function getPermissionedCampaigns(
* @return bool
*/
public static function isCampaignEnable(): bool {
- return in_array('CiviCampaign', CRM_Core_Config::singleton()->enableComponents, TRUE);
+ return CRM_Core_Component::isEnabled('CiviCampaign');
}
/**
diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php
index cf705043eebc..7dc618131811 100644
--- a/CRM/Case/BAO/Case.php
+++ b/CRM/Case/BAO/Case.php
@@ -34,8 +34,7 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
* @return bool
*/
public static function enabled() {
- $config = CRM_Core_Config::singleton();
- return in_array('CiviCase', $config->enableComponents);
+ return CRM_Core_Component::isEnabled('CiviCase');
}
/**
diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php
index 82576b3ced9e..9667903c3e1a 100644
--- a/CRM/Contact/BAO/Contact.php
+++ b/CRM/Contact/BAO/Contact.php
@@ -3268,7 +3268,7 @@ public static function checkUserMenuPermissions($aclPermissionedTasks, $corePerm
$componentName = $menuOptions['component'] ?? NULL;
// if component action - make sure component is enable.
- if ($componentName && !in_array($componentName, CRM_Core_Config::singleton()->enableComponents)) {
+ if ($componentName && !CRM_Core_Component::isEnabled($componentName)) {
return FALSE;
}
diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php
index b7f17717973e..7a58a71eb2b1 100644
--- a/CRM/Contribute/Form/Contribution.php
+++ b/CRM/Contribute/Form/Contribution.php
@@ -266,7 +266,7 @@ public function preProcess() {
$this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
- if (in_array('CiviPledge', CRM_Core_Config::singleton()->enableComponents) && !$this->_formType) {
+ if (CRM_Core_Component::isEnabled('CiviPledge') && !$this->_formType) {
$this->preProcessPledge();
}
diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php
index f1a1536dc91f..bc9ec89272b9 100644
--- a/CRM/Contribute/Form/Contribution/Confirm.php
+++ b/CRM/Contribute/Form/Contribution/Confirm.php
@@ -520,8 +520,7 @@ public function buildQuickForm() {
$this->set('productID', $productID);
$this->set('option', $option);
}
- $config = CRM_Core_Config::singleton();
- if (in_array('CiviMember', $config->enableComponents) && empty($this->_ccid)) {
+ if (CRM_Core_Component::isEnabled('CiviMember') && empty($this->_ccid)) {
if (isset($params['selectMembership']) &&
$params['selectMembership'] !== 'no_thanks'
) {
diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php
index fada03f546cb..17db610f090d 100644
--- a/CRM/Contribute/Form/Contribution/Main.php
+++ b/CRM/Contribute/Form/Contribution/Main.php
@@ -426,8 +426,7 @@ public function buildQuickForm() {
//don't build pledge block when mid is passed
if (!$this->_mid && empty($this->_ccid)) {
- $config = CRM_Core_Config::singleton();
- if (in_array('CiviPledge', $config->enableComponents) && !empty($this->_values['pledge_block_id'])) {
+ if (CRM_Core_Component::isEnabled('CiviPledge') && !empty($this->_values['pledge_block_id'])) {
CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
}
}
diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php
index 87c71b7914aa..f9bd0a367768 100644
--- a/CRM/Contribute/Form/ContributionBase.php
+++ b/CRM/Contribute/Form/ContributionBase.php
@@ -526,7 +526,6 @@ public function assignToTemplate() {
'amount_level',
];
- $config = CRM_Core_Config::singleton();
if (isset($this->_values['is_recur']) && !empty($this->_paymentProcessor['is_recur'])) {
$this->assign('is_recur_enabled', 1);
$vars = array_merge($vars, [
@@ -537,9 +536,10 @@ public function assignToTemplate() {
]);
}
- if (in_array('CiviPledge', $config->enableComponents) &&
- CRM_Utils_Array::value('is_pledge', $this->_params) == 1
+ if (CRM_Core_Component::isEnabled('CiviPledge') &&
+ !empty($this->_params['is_pledge'])
) {
+ // TODO: Assigned variable appears to be unused
$this->assign('pledge_enabled', 1);
$vars = array_merge($vars, [
diff --git a/CRM/Contribute/Form/ContributionPage/Amount.php b/CRM/Contribute/Form/ContributionPage/Amount.php
index d763f11f0c2c..2a2a43546dd9 100644
--- a/CRM/Contribute/Form/ContributionPage/Amount.php
+++ b/CRM/Contribute/Form/ContributionPage/Amount.php
@@ -152,8 +152,7 @@ public function buildQuickForm() {
]);
//CiviPledge fields.
- $config = CRM_Core_Config::singleton();
- if (in_array('CiviPledge', $config->enableComponents)) {
+ if (CRM_Core_Component::isEnabled('CiviPledge')) {
$this->assign('civiPledge', TRUE);
$this->addElement('checkbox', 'is_pledge_active', ts('Pledges'),
NULL, ['onclick' => "showHideAmountBlock( this, 'is_pledge_active' ); return showHideByValue('is_pledge_active',true,'pledgeFields','table-row','radio',false);"]
diff --git a/CRM/Contribute/Page/ContributionPage.php b/CRM/Contribute/Page/ContributionPage.php
index 23d8536c9c35..9f96923ec30f 100644
--- a/CRM/Contribute/Page/ContributionPage.php
+++ b/CRM/Contribute/Page/ContributionPage.php
@@ -299,15 +299,11 @@ public function run() {
return $controller->run();
}
elseif ($action & CRM_Core_Action::UPDATE) {
- $config = CRM_Core_Config::singleton();
-
// assign vars to templates
$this->assign('id', $id);
$this->assign('title', CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $id, 'title'));
$this->assign('is_active', CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $id, 'is_active'));
- if (in_array('CiviMember', $config->enableComponents)) {
- $this->assign('CiviMember', TRUE);
- }
+ $this->assign('CiviMember', CRM_Core_Component::isEnabled('CiviMember'));
}
elseif ($action & CRM_Core_Action::COPY) {
// @todo Unused local variable can be safely removed.
diff --git a/CRM/Contribute/StateMachine/ContributionPage.php b/CRM/Contribute/StateMachine/ContributionPage.php
index 4c17a71edaaa..e3d74b899d78 100644
--- a/CRM/Contribute/StateMachine/ContributionPage.php
+++ b/CRM/Contribute/StateMachine/ContributionPage.php
@@ -34,8 +34,6 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) {
$session = CRM_Core_Session::singleton();
$session->set('singleForm', FALSE);
- $config = CRM_Core_Config::singleton();
-
$this->_pages = [
'CRM_Contribute_Form_ContributionPage_Settings' => NULL,
'CRM_Contribute_Form_ContributionPage_Amount' => NULL,
@@ -48,7 +46,7 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) {
'CRM_Contribute_Form_ContributionPage_Widget' => NULL,
];
- if (!in_array("CiviMember", $config->enableComponents)) {
+ if (!CRM_Core_Component::isEnabled('CiviMember')) {
unset($this->_pages['CRM_Member_Form_MembershipBlock']);
}
diff --git a/CRM/Core/BAO/Dashboard.php b/CRM/Core/BAO/Dashboard.php
index 5ef7321b15f8..d0866aceeca8 100644
--- a/CRM/Core/BAO/Dashboard.php
+++ b/CRM/Core/BAO/Dashboard.php
@@ -142,8 +142,6 @@ public static function initializeDashlets() {
*/
public static function checkPermission($permissions, $operator) {
if ($permissions) {
- $config = CRM_Core_Config::singleton();
-
static $allComponents;
if (!$allComponents) {
$allComponents = CRM_Core_Component::getNames();
@@ -170,9 +168,7 @@ public static function checkPermission($permissions, $operator) {
//hack to determine if it's a component related permission
if ($componentName) {
- if (!in_array($componentName, $config->enableComponents) ||
- !CRM_Core_Permission::check($key)
- ) {
+ if (!CRM_Core_Component::isEnabled($componentName) || !CRM_Core_Permission::check($key)) {
$showDashlet = FALSE;
if ($operator == 'AND') {
return $showDashlet;
diff --git a/CRM/Core/BAO/Navigation.php b/CRM/Core/BAO/Navigation.php
index 28499d367688..52775d3fd3ef 100644
--- a/CRM/Core/BAO/Navigation.php
+++ b/CRM/Core/BAO/Navigation.php
@@ -368,9 +368,7 @@ public static function checkPermission($item) {
$componentName = CRM_Core_Permission::getComponentName($key);
if ($componentName) {
- if (!in_array($componentName, CRM_Core_Config::singleton()->enableComponents) ||
- !CRM_Core_Permission::check($key)
- ) {
+ if (!CRM_Core_Component::isEnabled($componentName) || !CRM_Core_Permission::check($key)) {
$showItem = FALSE;
if ($operator == 'AND') {
return FALSE;
diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php
index c3c929d01679..cbf2aac51e31 100644
--- a/CRM/Core/BAO/UFGroup.php
+++ b/CRM/Core/BAO/UFGroup.php
@@ -3455,8 +3455,7 @@ public static function groupTypeValues($profileId, $groupType = NULL) {
*/
public static function isProfileDoubleOptin() {
// check for double optin
- $config = CRM_Core_Config::singleton();
- if (in_array('CiviMail', $config->enableComponents)) {
+ if (CRM_Core_Component::isEnabled('CiviMail')) {
return Civi::settings()->get('profile_double_optin');
}
return FALSE;
@@ -3467,8 +3466,7 @@ public static function isProfileDoubleOptin() {
*/
public static function isProfileAddToGroupDoubleOptin() {
// check for add to group double optin
- $config = CRM_Core_Config::singleton();
- if (in_array('CiviMail', $config->enableComponents)) {
+ if (CRM_Core_Component::isEnabled('CiviMail')) {
return Civi::settings()->get('profile_add_to_group_double_optin');
}
return FALSE;
diff --git a/CRM/Core/Block.php b/CRM/Core/Block.php
index 68164605735f..cdde5b928e8d 100644
--- a/CRM/Core/Block.php
+++ b/CRM/Core/Block.php
@@ -326,8 +326,6 @@ private static function setTemplateValues($id) {
* Create the list of options to create New objects for the application and format is as a block.
*/
private static function setTemplateShortcutValues() {
- $config = CRM_Core_Config::singleton();
-
static $shortCuts = [];
if (!($shortCuts)) {
@@ -349,14 +347,12 @@ private static function setTemplateShortcutValues() {
$components = CRM_Core_Component::getEnabledComponents();
- if (!empty($config->enableComponents)) {
+ if ($components) {
// check if we can process credit card contribs
$newCredit = CRM_Core_Config::isEnabledBackOfficeCreditCardPayments();
- foreach ($components as $componentName => $obj) {
- if (in_array($componentName, $config->enableComponents)) {
- $obj->creatNewShortcut($shortCuts, $newCredit);
- }
+ foreach ($components as $obj) {
+ $obj->creatNewShortcut($shortCuts, $newCredit);
}
}
diff --git a/CRM/Core/Component/Info.php b/CRM/Core/Component/Info.php
index 0aa9fb4cdf6b..a56e6fa4ed5f 100644
--- a/CRM/Core/Component/Info.php
+++ b/CRM/Core/Component/Info.php
@@ -220,8 +220,7 @@ abstract public function getActivityTypes();
* true if component is enabled, false if not
*/
public function isEnabled() {
- $config = CRM_Core_Config::singleton();
- return in_array($this->info['name'], $config->enableComponents, TRUE);
+ return CRM_Core_Component::isEnabled($this->info['name']);
}
/**
diff --git a/CRM/Core/Form/ShortCode.php b/CRM/Core/Form/ShortCode.php
index 58ce68a55b2e..ca526ee06eba 100644
--- a/CRM/Core/Form/ShortCode.php
+++ b/CRM/Core/Form/ShortCode.php
@@ -53,8 +53,6 @@ class CRM_Core_Form_ShortCode extends CRM_Core_Form {
* Build form data. Can be modified via hook_civicrm_preProcess.
*/
public function preProcess() {
- $config = CRM_Core_Config::singleton();
-
$this->components['user-dashboard'] = [
'label' => ts("User Dashboard"),
'select' => NULL,
@@ -73,7 +71,7 @@ public function preProcess() {
],
];
- if (in_array('CiviContribute', $config->enableComponents)) {
+ if (CRM_Core_Component::isEnabled('CiviContribute')) {
$this->components['contribution'] = [
'label' => ts("Contribution Page"),
'select' => [
@@ -92,7 +90,7 @@ public function preProcess() {
];
}
- if (in_array('CiviEvent', $config->enableComponents)) {
+ if (CRM_Core_Component::isEnabled('CiviEvent')) {
$this->components['event'] = [
'label' => ts("Event Page"),
'select' => [
@@ -103,7 +101,7 @@ public function preProcess() {
];
}
- if (in_array('CiviCampaign', $config->enableComponents)) {
+ if (CRM_Core_Component::isEnabled('CiviCampaign')) {
$this->components['petition'] = [
'label' => ts("Petition"),
'select' => [
diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php
index 47b0350d7b8e..8645a836847d 100644
--- a/CRM/Core/Permission.php
+++ b/CRM/Core/Permission.php
@@ -423,9 +423,7 @@ public static function eventClause($type = CRM_Core_Permission::VIEW, $prefix =
* Access to specified $module is granted.
*/
public static function access($module, $checkPermission = TRUE, $requireAllCasesPermOnCiviCase = FALSE) {
- $config = CRM_Core_Config::singleton();
-
- if (!in_array($module, $config->enableComponents)) {
+ if (!CRM_Core_Component::isEnabled($module)) {
return FALSE;
}
diff --git a/CRM/Event/Form/ManageEvent.php b/CRM/Event/Form/ManageEvent.php
index 292e8b2b4c85..4f2030fd8498 100644
--- a/CRM/Event/Form/ManageEvent.php
+++ b/CRM/Event/Form/ManageEvent.php
@@ -88,10 +88,7 @@ public function getDefaultContext() {
* Set variables up before form is built.
*/
public function preProcess() {
- $config = CRM_Core_Config::singleton();
- if (in_array('CiviEvent', $config->enableComponents)) {
- $this->assign('CiviEvent', TRUE);
- }
+ $this->assign('CiviEvent', CRM_Core_Component::isEnabled('CiviEvent'));
CRM_Core_Form_RecurringEntity::preProcess('civicrm_event');
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
@@ -354,8 +351,7 @@ public function endPostProcess() {
[1 => CRM_Utils_Array::value('title', CRM_Utils_Array::value($subPage, $this->get('tabHeader')), $className)]
), $this->getTitle(), 'success');
- $config = CRM_Core_Config::singleton();
- if (in_array('CiviCampaign', $config->enableComponents)) {
+ if (CRM_Core_Component::isEnabled('CiviCampaign')) {
$values = $this->controller->exportValues($this->_name);
$newCampaignID = $values['campaign_id'] ?? NULL;
$eventID = $values['id'] ?? NULL;
diff --git a/CRM/Mailing/Info.php b/CRM/Mailing/Info.php
index c670df0d9644..bca7024211a6 100644
--- a/CRM/Mailing/Info.php
+++ b/CRM/Mailing/Info.php
@@ -41,7 +41,6 @@ public static function createAngularSettings():array {
}
}
- $config = CRM_Core_Config::singleton();
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
@@ -95,7 +94,7 @@ public static function createAngularSettings():array {
$crmMailingSettings = [
'templateTypes' => CRM_Mailing_BAO_Mailing::getTemplateTypes(),
'civiMails' => [],
- 'campaignEnabled' => in_array('CiviCampaign', $config->enableComponents),
+ 'campaignEnabled' => CRM_Core_Component::isEnabled('CiviCampaign'),
'groupNames' => [],
// @todo this is not used in core. Remove once Mosaico no longer depends on it.
'testGroupNames' => $groupNames['values'],
diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php
index d191d1b732c1..692894151b16 100644
--- a/CRM/Report/Form.php
+++ b/CRM/Report/Form.php
@@ -4399,9 +4399,7 @@ public function selectedTables() {
*/
public function addCampaignFields($entityTable = 'civicrm_contribution', $groupBy = FALSE, $orderBy = FALSE, $filters = TRUE) {
// Check if CiviCampaign is a) enabled and b) has active campaigns
- $config = CRM_Core_Config::singleton();
- $campaignEnabled = in_array('CiviCampaign', $config->enableComponents);
- if ($campaignEnabled) {
+ if (CRM_Core_Component::isEnabled('CiviCampaign')) {
$getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, FALSE, FALSE, TRUE);
// If we have a campaign, build out the relevant elements
if (!empty($getCampaigns['campaigns'])) {
diff --git a/CRM/Report/Form/Activity.php b/CRM/Report/Form/Activity.php
index d91c95e01065..9fda9efae5f8 100644
--- a/CRM/Report/Form/Activity.php
+++ b/CRM/Report/Form/Activity.php
@@ -700,8 +700,7 @@ public function add2group($groupID) {
*/
public static function formRule($fields, $files, $self) {
$errors = [];
- $config = CRM_Core_Config::singleton();
- if (in_array("CiviCase", $config->enableComponents)) {
+ if (CRM_Core_Component::isEnabled('CiviCase')) {
$componentId = CRM_Core_Component::getComponentID('CiviCase');
$caseActivityTypes = CRM_Core_OptionGroup::values('activity_type', TRUE, FALSE, FALSE, " AND v.component_id={$componentId}");
if (!empty($fields['activity_type_id_value']) && is_array($fields['activity_type_id_value']) && empty($fields['include_case_activities_value'])) {
diff --git a/CRM/Report/Page/InstanceList.php b/CRM/Report/Page/InstanceList.php
index 96c31a479987..a327304d375a 100644
--- a/CRM/Report/Page/InstanceList.php
+++ b/CRM/Report/Page/InstanceList.php
@@ -134,7 +134,6 @@ public function info() {
$dao = CRM_Core_DAO::executeQuery($sql, $queryParams);
- $config = CRM_Core_Config::singleton();
$rows = [];
$url = 'civicrm/report/instance';
$my_reports_grouping = 'My';
@@ -143,7 +142,7 @@ public function info() {
continue;
}
- $enabled = in_array("Civi{$dao->compName}", $config->enableComponents);
+ $enabled = CRM_Core_Component::isEnabled("Civi{$dao->compName}");
if ($dao->compName == 'Contact' || $dao->compName == $dao->grouping) {
$enabled = TRUE;
}
diff --git a/CRM/Report/Page/TemplateList.php b/CRM/Report/Page/TemplateList.php
index eb24cafac18b..2b69ada6f5cd 100644
--- a/CRM/Report/Page/TemplateList.php
+++ b/CRM/Report/Page/TemplateList.php
@@ -68,10 +68,9 @@ public static function &info($compID = NULL, $grouping = NULL) {
$dao = CRM_Core_DAO::executeQuery($sql);
$rows = [];
- $config = CRM_Core_Config::singleton();
while ($dao->fetch()) {
if ($dao->component_name != 'Contact' && $dao->component_name != $dao->grouping &&
- !in_array("Civi{$dao->component_name}", $config->enableComponents)
+ !CRM_Core_Component::isEnabled("Civi{$dao->component_name}")
) {
continue;
}
diff --git a/CRM/Upgrade/Incremental/php/FiveFortySeven.php b/CRM/Upgrade/Incremental/php/FiveFortySeven.php
index 1f5fe04ea315..08135fdf24ab 100644
--- a/CRM/Upgrade/Incremental/php/FiveFortySeven.php
+++ b/CRM/Upgrade/Incremental/php/FiveFortySeven.php
@@ -96,7 +96,7 @@ public static function updateRelationshipDates(CRM_Queue_TaskContext $ctx): bool
* @throws \Civi\API\Exception\NotImplementedException
*/
public static function migrateCiviGrant(CRM_Queue_TaskContext $ctx): bool {
- $civiGrantEnabled = in_array('CiviGrant', Civi::settings()->get('enable_components'), TRUE);
+ $civiGrantEnabled = CRM_Core_Component::isEnabled('CiviGrant');
if ($civiGrantEnabled) {
CRM_Core_BAO_ConfigSetting::disableComponent('CiviGrant');
}
diff --git a/CRM/Upgrade/Incremental/php/FiveThirteen.php b/CRM/Upgrade/Incremental/php/FiveThirteen.php
index c898677d069b..74fc0321bf8a 100644
--- a/CRM/Upgrade/Incremental/php/FiveThirteen.php
+++ b/CRM/Upgrade/Incremental/php/FiveThirteen.php
@@ -23,9 +23,7 @@ class CRM_Upgrade_Incremental_php_FiveThirteen extends CRM_Upgrade_Incremental_B
* an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
*/
public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
- $config = CRM_Core_Config::singleton();
- $campaignEnabled = in_array("CiviCampaign", $config->enableComponents);
- if ($rev == '5.13.alpha1' && $campaignEnabled) {
+ if ($rev == '5.13.alpha1' && CRM_Core_Component::isEnabled('CiviCampaign')) {
$postUpgradeMessage .= '
' . ts("If you have created a report based on the Mailing Summary Report template and it outputs or filters on campaigns, You will need to go back to that report and re-save the report after selecting and or setting the campaign filters up again");
}
}
diff --git a/CRM/Upgrade/Incremental/php/FiveTwenty.php b/CRM/Upgrade/Incremental/php/FiveTwenty.php
index 6efa9f9b6bb7..1edbef463cd7 100644
--- a/CRM/Upgrade/Incremental/php/FiveTwenty.php
+++ b/CRM/Upgrade/Incremental/php/FiveTwenty.php
@@ -39,8 +39,7 @@ public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NU
]);
}
- $config = CRM_Core_Config::singleton();
- if (in_array('CiviCase', $config->enableComponents)) {
+ if (CRM_Core_Component::isEnabled('CiviCase')) {
// Do dry-run to get warning messages.
$messages = self::_changeCaseTypeLabelToName(TRUE);
foreach ($messages as $message) {
@@ -62,8 +61,7 @@ public function upgrade_5_20_alpha1($rev) {
"tinyint(4) DEFAULT '0' COMMENT 'Shows this is a template for recurring contributions.'", FALSE, '5.20.alpha1');
$this->addTask('Add order_reference field to civicrm_financial_trxn', 'addColumn', 'civicrm_financial_trxn', 'order_reference',
"varchar(255) COMMENT 'Payment Processor external order reference'", FALSE, '5.20.alpha1');
- $config = CRM_Core_Config::singleton();
- if (in_array('CiviCase', $config->enableComponents)) {
+ if (CRM_Core_Component::isEnabled('CiviCase')) {
$this->addTask('Change direction of autoassignees in case type xml', 'changeCaseTypeAutoassignee');
$this->addTask('Change labels back to names in case type xml', 'changeCaseTypeLabelToName');
}
diff --git a/CRM/Utils/Check/Component/Env.php b/CRM/Utils/Check/Component/Env.php
index f07641564937..064f5f012295 100644
--- a/CRM/Utils/Check/Component/Env.php
+++ b/CRM/Utils/Check/Component/Env.php
@@ -251,9 +251,7 @@ public function checkDefaultMailbox($force = FALSE) {
return $messages;
}
- $config = CRM_Core_Config::singleton();
-
- if (in_array('CiviMail', $config->enableComponents) &&
+ if (CRM_Core_Component::isEnabled('CiviMail') &&
CRM_Core_BAO_MailSettings::defaultDomain() == "EXAMPLE.ORG"
) {
$message = new CRM_Utils_Check_Message(
diff --git a/Civi/Api4/RelationshipCache.php b/Civi/Api4/RelationshipCache.php
index 77db19c2f2d7..3beee1ab4303 100644
--- a/Civi/Api4/RelationshipCache.php
+++ b/Civi/Api4/RelationshipCache.php
@@ -53,7 +53,7 @@ public static function getInfo() {
'description' => ts('One or more related contacts'),
],
];
- if (in_array('CiviCase', \Civi::settings()->get('enable_components'), TRUE)) {
+ if (\CRM_Core_Component::isEnabled('CiviCase')) {
$info['bridge']['case_id'] = [
'to' => 'far_contact_id',
'label' => ts('Case Roles'),
diff --git a/Civi/Api4/Service/Spec/SpecGatherer.php b/Civi/Api4/Service/Spec/SpecGatherer.php
index d166207bda1b..e37656747f6a 100644
--- a/Civi/Api4/Service/Spec/SpecGatherer.php
+++ b/Civi/Api4/Service/Spec/SpecGatherer.php
@@ -92,9 +92,7 @@ private function addDAOFields($entity, $action, RequestSpec $spec) {
if (array_key_exists('contactType', $DAOField) && $spec->getValue('contact_type') && $DAOField['contactType'] != $spec->getValue('contact_type')) {
continue;
}
- if (!empty($DAOField['component']) &&
- !in_array($DAOField['component'], \Civi::settings()->get('enable_components'), TRUE)
- ) {
+ if (!empty($DAOField['component']) && !\CRM_Core_Component::isEnabled($DAOField['component'])) {
continue;
}
if ($DAOField['name'] == 'is_active' && empty($DAOField['default'])) {
diff --git a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Case.php b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Case.php
index dcc9bd71f498..dfd812c4c8e0 100644
--- a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Case.php
+++ b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Case.php
@@ -29,8 +29,7 @@ public function __construct() {
* @return bool
*/
public function isActive() {
- $config = CRM_Core_Config::singleton();
- return in_array('CiviCase', $config->enableComponents);
+ return CRM_Core_Component::isEnabled('CiviCase');
}
/**
diff --git a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Contribution.php b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Contribution.php
index 78ec8d6b20da..913bb85cadb5 100644
--- a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Contribution.php
+++ b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Contribution.php
@@ -29,9 +29,8 @@ public function __construct() {
* @return bool
*/
public function isActive() {
- $config = CRM_Core_Config::singleton();
- return in_array('CiviContribute', $config->enableComponents) &&
- CRM_Core_Permission::check('access CiviContribute');
+ return CRM_Core_Component::isEnabled('CiviContribute') &&
+ CRM_Core_Permission::check('access CiviContribute');
}
/**
diff --git a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Membership.php b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Membership.php
index b56940cbed22..3d142fe7e182 100644
--- a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Membership.php
+++ b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Membership.php
@@ -29,9 +29,8 @@ public function __construct() {
* @return bool
*/
public function isActive() {
- $config = CRM_Core_Config::singleton();
- return in_array('CiviMember', $config->enableComponents) &&
- CRM_Core_Permission::check('access CiviMember');
+ return CRM_Core_Component::isEnabled('CiviMember') &&
+ CRM_Core_Permission::check('access CiviMember');
}
/**
diff --git a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Participant.php b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Participant.php
index a24ce0d40731..7012b47dbf53 100644
--- a/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Participant.php
+++ b/ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText/Participant.php
@@ -29,9 +29,8 @@ public function __construct() {
* @return bool
*/
public function isActive() {
- $config = CRM_Core_Config::singleton();
- return in_array('CiviEvent', $config->enableComponents) &&
- CRM_Core_Permission::check('view event participants');
+ return CRM_Core_Component::isEnabled('CiviEvent') &&
+ CRM_Core_Permission::check('view event participants');
}
/**