From: Tim Otten Date: Tue, 17 Sep 2013 07:21:28 +0000 (-0700) Subject: CRM-13410 - Allow "Components" to define managed-entities X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3bd831aa8135922b3bdbdb677dce82410b413901;p=civicrm-core.git CRM-13410 - Allow "Components" to define managed-entities ---------------------------------------- * CRM-13410: Allow extensions to define case-types http://issues.civicrm.org/jira/browse/CRM-13410 --- diff --git a/CRM/Core/Component/Info.php b/CRM/Core/Component/Info.php index ef6a8dd5af..2913bc3d72 100644 --- a/CRM/Core/Component/Info.php +++ b/CRM/Core/Component/Info.php @@ -126,6 +126,16 @@ abstract class CRM_Core_Component_Info { */ abstract public function getInfo(); + /** + * Get a list of entities to register via API + * + * @return array list of entities; same format as CRM_Utils_Hook::managedEntities(&$entities) + * @see CRM_Utils_Hook::managedEntities + */ + public function getManagedEntities() { + return array(); + } + /** * Provides permissions that are used by component. * Needs to be implemented in component's information diff --git a/CRM/Core/ManagedEntities.php b/CRM/Core/ManagedEntities.php index a1b08c8fa4..1c0c565555 100644 --- a/CRM/Core/ManagedEntities.php +++ b/CRM/Core/ManagedEntities.php @@ -23,6 +23,9 @@ class CRM_Core_ManagedEntities { static $singleton; if ($fresh || !$singleton) { $declarations = array(); + foreach (CRM_Core_Component::getEnabledComponents() as $component) { + $declarations = array_merge($declarations, $component->getManagedEntities()); + } CRM_Utils_Hook::managed($declarations); $singleton = new CRM_Core_ManagedEntities(CRM_Core_Module::getAll(), $declarations); } @@ -99,7 +102,7 @@ class CRM_Core_ManagedEntities { $dao->module = $module->name; $dao->find(); while ($dao->fetch()) { - if ($todos[$dao->name]) { + if (isset($todos[$dao->name]) && $todos[$dao->name]) { // update existing entity; remove from $todos $defaults = array('id' => $dao->entity_id, 'is_active' => 1); // FIXME: test whether is_active is valid $params = array_merge($defaults, $todos[$dao->name]['params']);