[REF] CoreResources - Simplify disabled component check
[civicrm-core.git] / CRM / Core / Resources.php
index 0e4485c6adfd69929689a821860bab88b93918e3..6d83c2aa97da9ca0855af70d17b03fd7062b0e44 100644 (file)
@@ -501,22 +501,12 @@ class CRM_Core_Resources implements CRM_Core_Resources_CollectionAdderInterface
       'filters' => [],
       'links' => [],
     ];
-    $config = CRM_Core_Config::singleton();
-
-    $disabledComponents = [];
-    $dao = CRM_Core_DAO::executeQuery("SELECT name, namespace FROM civicrm_component");
-    while ($dao->fetch()) {
-      if (!in_array($dao->name, $config->enableComponents)) {
-        $disabledComponents[$dao->name] = $dao->namespace;
-      }
-    }
+    $enabledComponents = Civi::settings()->get('enable_components');
 
     foreach (CRM_Core_DAO_AllCoreTables::daoToClass() as $entity => $daoName) {
       // Skip DAOs of disabled components
-      foreach ($disabledComponents as $nameSpace) {
-        if (strpos($daoName, $nameSpace) === 0) {
-          continue 2;
-        }
+      if (defined("$daoName::COMPONENT") && !in_array($daoName::COMPONENT, $enabledComponents, TRUE)) {
+        continue;
       }
       $baoName = str_replace('_DAO_', '_BAO_', $daoName);
       if (class_exists($baoName)) {