CRM_Core_BAO_ConfigSetting - Support components from extensions
authorTim Otten <totten@civicrm.org>
Wed, 12 Aug 2015 07:48:04 +0000 (00:48 -0700)
committerTim Otten <totten@civicrm.org>
Thu, 13 Aug 2015 01:54:41 +0000 (18:54 -0700)
CRM/Core/BAO/ConfigSetting.php
CRM/Core/Component.php

index 3a5ff2a507ca8ec463ff75f4f98bf500a4625929..2183dbaff6c617c7a1c402058af2bddb5d75cafb 100644 (file)
@@ -347,10 +347,12 @@ class CRM_Core_BAO_ConfigSetting {
       if (!empty($enableComponents)) {
         $defaults['enableComponents'] = $enableComponents;
 
-        $components = CRM_Core_Component::getComponents();
+        // Lookup component IDs. Note: Do *not* instantiate components.
+        // Classloading may not be fully setup yet.
+        $components = CRM_Core_Component::getComponentIDs();
         $enabledComponentIDs = array();
         foreach ($defaults['enableComponents'] as $name) {
-          $enabledComponentIDs[] = $components[$name]->componentID;
+          $enabledComponentIDs[] = $components[$name];
         }
         $defaults['enableComponentIDs'] = $enabledComponentIDs;
       }
index 9f099617fd9fa7f62429fc9f88affc9342e620f5..da70a18ef1271d96a814781a838e12e42bf445dc 100644 (file)
@@ -112,6 +112,23 @@ class CRM_Core_Component {
     return $_cache;
   }
 
+  /**
+   * @return array
+   *   Array(string $name => int $id).
+   */
+  public static function &getComponentIDs() {
+    $componentIDs = array();
+
+    $cr = new CRM_Core_DAO_Component();
+    $cr->find(FALSE);
+    while ($cr->fetch()) {
+      $componentIDs[$cr->name] = $cr->id;
+    }
+
+    return $componentIDs;
+  }
+
+
   /**
    * @param bool $force
    *