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;
}
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
*