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);
}
$dao->name = $name;
if ($dao->find(TRUE)) {
$params = array(
- 'version' => 3,
'id' => $dao->entity_id,
);
- $result = civicrm_api($dao->entity_type, 'getsingle', $params);
- if ($result['is_error']) {
+ try {
+ $result = civicrm_api3($dao->entity_type, 'getsingle', $params);
+ }
+ catch (Exception $e) {
$this->onApiError($params, $result);
- } else {
- return $result;
}
+ return $result;
} else {
return NULL;
}
/**
* Create, update, and delete entities declared by an active module
*
- * @param $module string
+ * @param \CRM_Core_Module|string $module string
* @param $todos array $name => array()
*/
public function reconcileEnabledModule(CRM_Core_Module $module, $todos) {
$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']);
}
/**
+ * @param $modules
+ *
* @return array indexed by is_active,name
*/
protected static function createModuleIndex($modules) {
}
/**
+ * @param $moduleIndex
+ * @param $declarations
+ *
* @return array indexed by module,name
*/
protected static function createDeclarationIndex($moduleIndex, $declarations) {
}
/**
+ * @param $declarations
+ *
* @return mixed string on error, or FALSE
*/
protected static function validate($declarations) {