Components - Use extracted function
authorColeman Watts <coleman@civicrm.org>
Wed, 19 Jan 2022 16:01:30 +0000 (11:01 -0500)
committerColeman Watts <coleman@civicrm.org>
Wed, 19 Jan 2022 16:01:30 +0000 (11:01 -0500)
Uses function extracted in #22567

CRM/Contact/BAO/Contact.php
CRM/Contribute/BAO/ContributionPage.php
CRM/Core/Resources.php
CRM/Event/BAO/Event.php
CRM/Upgrade/Incremental/php/FiveFortyThree.php
Civi/API/Request.php
Civi/Api4/Action/Entity/Get.php

index 0a707dfddd195a93e79c6670113daef3522015c5..725859fcd547b0c58ae96492d309881d1a6bba94 100644 (file)
@@ -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;
index a523e252a3e99e8cd7546f98dd65a3002885dcfd..5b9e725c9a067aa5f5c12752fced67caac190be1 100644 (file)
@@ -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);
         }
index 5487920d80c57de7cac2d4884461821568ea0d93..6945376e6120e76d07d63190ef7cbc3ca1b86ee1 100644 (file)
@@ -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);
index df4f8157a3d0d0de17dc851d69072ea2b587010b..20534481a0cd726567dbf5732a11899273fc31d7 100644 (file)
@@ -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 [];
index 5262a52fc126645bdb1815ec079fe73d326c60b7..b1c0a42c7637906445ad078f816d22ffe6f94863 100644 (file)
@@ -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 .= '<p>' . 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') . '</p>';
     }
   }
index 45616d4d1279a41c9ff19972e195191d3f8103a6..3a8d2da50b6b0b57dd291b594d9fdaa662391a76 100644 (file)
@@ -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);
index 3e98e7f348abe56eb6119a47b1d037b08bbbc15e..69d64e409b7b5694a5fe1e6b4653aea94b38d7db 100644 (file)
@@ -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;
     }
   }