本文整理汇总了PHP中CRM_Utils_Hook::caseTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Hook::caseTypes方法的具体用法?PHP CRM_Utils_Hook::caseTypes怎么用?PHP CRM_Utils_Hook::caseTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Hook
的用法示例。
在下文中一共展示了CRM_Utils_Hook::caseTypes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getManagedEntities
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();
$caseTypesGroupId = civicrm_api3('OptionGroup', 'getvalue', array('name' => 'case_type', 'return' => 'id'));
if (!is_numeric($caseTypesGroupId)) {
throw new CRM_Core_Exception("Found invalid ID for OptionGroup (case_type)");
}
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' => 'OptionValue', 'params' => array('version' => 3, 'name' => $caseType['name'], 'label' => (string) $xml->name, 'description' => (string) $xml->description, 'option_group_id' => $caseTypesGroupId, 'is_reserved' => 1));
} else {
throw new CRM_Core_Exception("Invalid case type");
}
}
return $entities;
}
示例2: retrieve
function retrieve($caseType)
{
$caseType = self::mungeCaseType($caseType);
if (!CRM_Utils_Array::value($caseType, self::$_xml)) {
if (!self::$_xml) {
self::$_xml = array();
}
// first check custom templates directory
$fileName = NULL;
$config = CRM_Core_Config::singleton();
if (isset($config->customTemplateDir) && $config->customTemplateDir) {
// check if the file exists in the custom templates directory
$fileName = implode(DIRECTORY_SEPARATOR, array($config->customTemplateDir, 'CRM', 'Case', 'xml', 'configuration', "{$caseType}.xml"));
}
if (!$fileName || !file_exists($fileName)) {
// check if file exists locally
$fileName = implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), 'xml', 'configuration', "{$caseType}.xml"));
if (!file_exists($fileName)) {
// check if file exists locally
$fileName = implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), 'xml', 'configuration.sample', "{$caseType}.xml"));
}
if (!file_exists($fileName)) {
if (self::$_hookCache === NULL) {
self::$_hookCache = array();
CRM_Utils_Hook::caseTypes(self::$_hookCache);
}
if (isset(self::$_hookCache[$caseType], self::$_hookCache[$caseType]['file'])) {
$fileName = self::$_hookCache[$caseType]['file'];
}
}
if (!file_exists($fileName)) {
return FALSE;
}
}
// read xml file
$dom = new DomDocument();
$dom->load($fileName);
$dom->xinclude();
self::$_xml[$caseType] = simplexml_import_dom($dom);
}
return self::$_xml[$caseType];
}
示例3: createManagedCaseTypes
/**
* Get a list of managed-entities representing auto-generated case-types
* using hook_civicrm_caseTypes.
*
* @return array
* @see CRM_Utils_Hook::managed
* @throws CRM_Core_Exception
*/
public static function createManagedCaseTypes()
{
$entities = array();
// 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.
$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;
}
示例4: getCaseTypesViaHook
/**
* @return array
* @see CRM_Utils_Hook::caseTypes
*/
public function getCaseTypesViaHook()
{
if ($this->hookCache === NULL) {
$this->hookCache = array();
CRM_Utils_Hook::caseTypes($this->hookCache);
}
return $this->hookCache;
}