From: Coleman Watts Date: Wed, 19 Jan 2022 16:01:30 +0000 (-0500) Subject: Components - Use extracted function X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=cabcfae529bf34d6ca8420c2f7c04db5796a175a;p=civicrm-core.git Components - Use extracted function Uses function extracted in #22567 --- diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 0a707dfddd..725859fcd5 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -2728,13 +2728,13 @@ LEFT JOIN civicrm_email ON ( civicrm_contact.id = civicrm_email.contact_id ) return CRM_Core_BAO_Note::getContactNoteCount($contactId); case 'contribution': - if (array_key_exists('CiviContribute', CRM_Core_Component::getEnabledComponents())) { + if (CRM_Core_Component::isEnabled('CiviContribute')) { return CRM_Contribute_BAO_Contribution::contributionCount($contactId); } return FALSE; case 'membership': - if (array_key_exists('CiviMember', CRM_Core_Component::getEnabledComponents())) { + if (CRM_Core_Component::isEnabled('CiviMember')) { return CRM_Member_BAO_Membership::getContactMembershipCount((int) $contactId, TRUE); } return FALSE; diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index a523e252a3..5b9e725c9a 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -820,7 +820,7 @@ LEFT JOIN civicrm_premiums ON ( civicrm_premiums.entity_id = civicrm // @todo - the component is enabled check should be done within getIncomeFinancialType // It looks to me like test cover was NOT added to cover the change // that added this so we need to assume there is no test cover - if (array_key_exists('CiviContribute', CRM_Core_Component::getEnabledComponents())) { + if (CRM_Core_Component::isEnabled('CiviContribute')) { // if check_permission has been passed in (not Null) then restrict. return CRM_Financial_BAO_FinancialType::getIncomeFinancialType($props['check_permissions'] ?? TRUE); } diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 5487920d80..6945376e61 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -501,11 +501,10 @@ class CRM_Core_Resources implements CRM_Core_Resources_CollectionAdderInterface 'filters' => [], 'links' => [], ]; - $enabledComponents = Civi::settings()->get('enable_components'); foreach (CRM_Core_DAO_AllCoreTables::daoToClass() as $entity => $daoName) { // Skip DAOs of disabled components - if (defined("$daoName::COMPONENT") && !in_array($daoName::COMPONENT, $enabledComponents, TRUE)) { + if (defined("$daoName::COMPONENT") && !CRM_Core_Component::isEnabled($daoName::COMPONENT)) { continue; } $baoName = str_replace('_DAO_', '_BAO_', $daoName); diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index df4f8157a3..20534481a0 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -2357,7 +2357,7 @@ LEFT JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field // @todo - the component is enabled check should be done within getIncomeFinancialType // It looks to me like test cover was NOT added to cover the change // that added this so we need to assume there is no test cover - if (array_key_exists('CiviContribute', CRM_Core_Component::getEnabledComponents())) { + if (CRM_Core_Component::isEnabled('CiviContribute')) { return CRM_Financial_BAO_FinancialType::getIncomeFinancialType($props['check_permissions'] ?? TRUE); } return []; diff --git a/CRM/Upgrade/Incremental/php/FiveFortyThree.php b/CRM/Upgrade/Incremental/php/FiveFortyThree.php index 5262a52fc1..b1c0a42c76 100644 --- a/CRM/Upgrade/Incremental/php/FiveFortyThree.php +++ b/CRM/Upgrade/Incremental/php/FiveFortyThree.php @@ -26,7 +26,7 @@ class CRM_Upgrade_Incremental_php_FiveFortyThree extends CRM_Upgrade_Incremental * @param null $currentVer */ public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL): void { - if ($rev === '5.43.alpha1' && !empty(CRM_Core_Component::getEnabledComponents()['CiviCase'])) { + if ($rev === '5.43.alpha1' && CRM_Core_Component::isEnabled('CiviCase')) { $preUpgradeMessage .= '

' . ts('Minor changes have been made to how the tokens to render case.is_deleted, case.created_date and case.modified_date. See https://docs.civicrm.org/sysadmin/en/latest/upgrade/version-specific/ for more') . '

'; } } diff --git a/Civi/API/Request.php b/Civi/API/Request.php index 45616d4d12..3a8d2da50b 100644 --- a/Civi/API/Request.php +++ b/Civi/API/Request.php @@ -57,7 +57,7 @@ class Request { } // Check enabled components $daoName = \CRM_Core_DAO_AllCoreTables::getFullName($entity); - if ($daoName && defined("{$daoName}::COMPONENT") && !array_key_exists($daoName::COMPONENT, \CRM_Core_Component::getEnabledComponents())) { + if ($daoName && defined("{$daoName}::COMPONENT") && !\CRM_Core_Component::isEnabled($daoName::COMPONENT)) { throw new \Civi\API\Exception\NotImplementedException("$entity API is not available because " . $daoName::COMPONENT . " component is disabled"); } $apiRequest = call_user_func_array($callable, $e->args); diff --git a/Civi/Api4/Action/Entity/Get.php b/Civi/Api4/Action/Entity/Get.php index 3e98e7f348..69d64e409b 100644 --- a/Civi/Api4/Action/Entity/Get.php +++ b/Civi/Api4/Action/Entity/Get.php @@ -64,7 +64,7 @@ class Get extends \Civi\Api4\Generic\BasicGetAction { $info = $className::getInfo(); $daoName = $info['dao'] ?? NULL; // Only include DAO entities from enabled components - if (!$daoName || !defined("{$daoName}::COMPONENT") || array_key_exists($daoName::COMPONENT, \CRM_Core_Component::getEnabledComponents())) { + if (!$daoName || !defined("{$daoName}::COMPONENT") || \CRM_Core_Component::isEnabled($daoName::COMPONENT)) { $entities[$info['name']] = $info; } }