From: Nileema Date: Thu, 8 May 2014 13:21:30 +0000 (+0530) Subject: --Fix to support hook_civicrm_caseTypes X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=78650402bbdbc11e125c9eae560e4ddd1bfdbcca;p=civicrm-core.git --Fix to support hook_civicrm_caseTypes --- diff --git a/CRM/Case/Info.php b/CRM/Case/Info.php index b03c42b605..8ed9054fd7 100644 --- a/CRM/Case/Info.php +++ b/CRM/Case/Info.php @@ -52,6 +52,48 @@ class CRM_Case_Info extends CRM_Core_Component_Info { ); } + // docs inherited from interface + public function getManagedEntities() { + // Use hook_civicrm_caseTypes to build a list of OptionValues + // In the long run, we may want more specialized logic for this, but + // this design is fairly convenient and will allow us to replace it + // without changing the hook_civicrm_caseTypes interface. + $entities = array(); + + $caseTypes = array(); + CRM_Utils_Hook::caseTypes($caseTypes); + + $proc = new CRM_Case_XMLProcessor(); + foreach ($caseTypes as $name => $caseType) { + $xml = $proc->retrieve($name); + if (!$xml) { + throw new CRM_Core_Exception("Failed to load XML for case type (" . $name . ")"); + } + + if (isset($caseType['module'], $caseType['name'], $caseType['file'])) { + $entities[] = array( + 'module' => $caseType['module'], + 'name' => $caseType['name'], + 'entity' => 'CaseType', + 'params' => array( + 'version' => 3, + 'name' => $caseType['name'], + 'title' => (string) $xml->name, + 'description' => (string) $xml->description, + 'is_reserved' => 1, + 'is_active' => 1, + 'weight' => $xml->weight ? $xml->weight : 1, + ), + ); + } + else { + throw new CRM_Core_Exception("Invalid case type"); + } + } + + return $entities; + } + // docs inherited from interface public function getPermissions($getAllUnconditionally = FALSE) { return array(