X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FHook.php;h=bf0b47f4b7297e2b2d57e77fe0758d3e00785da2;hb=5dc8d80defb19ece6aed1a0b1a56dac949573ba2;hp=4024d2668dc40ae32a639ffdb6358dad9fa21c93;hpb=d08319ae7e2b45f66d945c2498d2b9396c334e28;p=civicrm-core.git diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index 4024d2668d..bf0b47f4b7 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -108,6 +108,19 @@ abstract class CRM_Utils_Hook { $fnSuffix ); + /** + * @param $numParams + * @param $arg1 + * @param $arg2 + * @param $arg3 + * @param $arg4 + * @param $arg5 + * @param $arg6 + * @param $fnSuffix + * @param $fnPrefix + * + * @return array|bool + */ function commonInvoke($numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix, $fnPrefix @@ -216,6 +229,9 @@ abstract class CRM_Utils_Hook { return empty($result) ? TRUE : $result; } + /** + * @param $moduleList + */ function requireCiviModules(&$moduleList) { $civiModules = CRM_Core_PseudoConstant::getModuleExtensions(); foreach ($civiModules as $civiModule) { @@ -243,6 +259,9 @@ abstract class CRM_Utils_Hook { * @return null the return value is ignored */ static function pre($op, $objectName, $id, &$params) { + $event = new \Civi\Core\Event\PreEvent($op, $objectName, $id, $params); + \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_pre", $event); + \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_pre::$objectName", $event); return self::singleton()->invoke(4, $op, $objectName, $id, $params, self::$_nullObject, self::$_nullObject, 'civicrm_pre'); } @@ -259,6 +278,9 @@ abstract class CRM_Utils_Hook { * @access public */ static function post($op, $objectName, $objectId, &$objectRef) { + $event = new \Civi\Core\Event\PostEvent($op, $objectName, $objectId, $objectRef); + \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_post", $event); + \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_post::$objectName", $event); return self::singleton()->invoke(4, $op, $objectName, $objectId, $objectRef, self::$_nullObject, self::$_nullObject, 'civicrm_post'); } @@ -456,6 +478,23 @@ abstract class CRM_Utils_Hook { ); } + /** + * Determine how many other records refer to a given record + * + * @param CRM_Core_DAO $dao the item for which we want a reference count + * @param array $refCounts each item in the array is an array with keys: + * - name: string, eg "sql:civicrm_email:contact_id" + * - type: string, eg "sql" + * - count: int, eg "5" if there are 5 email addresses that refer to $dao + * @return void + */ + static function referenceCounts($dao, &$refCounts) { + return self::singleton()->invoke(2, $dao, $refCounts, + self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, + 'civicrm_referenceCounts' + ); + } + /** * This hook is called when building the amount structure for a Contribution or Event Page * @@ -867,6 +906,13 @@ abstract class CRM_Utils_Hook { ); } + /** + * @param $recordBAO + * @param $recordID + * @param $isActive + * + * @return mixed + */ static function enableDisable($recordBAO, $recordID, $isActive) { return self::singleton()->invoke(3, $recordBAO, $recordID, $isActive, self::$_nullObject, self::$_nullObject, self::$_nullObject, @@ -1030,6 +1076,11 @@ abstract class CRM_Utils_Hook { ); } + /** + * @param $dao + * + * @return mixed + */ static function postSave(&$dao) { $hookName = 'civicrm_postSave_' . $dao->getTableName(); return self::singleton()->invoke(1, $dao, @@ -1273,6 +1324,13 @@ abstract class CRM_Utils_Hook { ); } + /** + * @param $varType + * @param $var + * @param $object + * + * @return mixed + */ static function alterReportVar($varType, &$var, &$object) { return self::singleton()->invoke(3, $varType, $var, $object, self::$_nullObject, @@ -1555,31 +1613,31 @@ abstract class CRM_Utils_Hook { /** * This hook is called before a case merge (or a case reassign) * - * @param type $mainContactId - * @param type $mainCaseId - * @param type $otherContactId - * @param type $otherCaseId - * @param bool|\type $changeClient + * @param integer $mainContactId + * @param integer $mainCaseId + * @param integer $otherContactId + * @param integer $otherCaseId + * @param bool $changeClient * * @return void */ static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) { - return self::singleton()->invoke(5, $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, 'civicrm_pre_case_merge'); + return self::singleton()->invoke(5, $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self::$_nullObject, 'civicrm_pre_case_merge'); } /** * This hook is called after a case merge (or a case reassign) * - * @param type $mainContactId - * @param type $mainCaseId - * @param type $otherContactId - * @param type $otherCaseId - * @param bool|\type $changeClient + * @param integer $mainContactId + * @param integer $mainCaseId + * @param integer $otherContactId + * @param integer $otherCaseId + * @param bool $changeClient * * @return void */ static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) { - return self::singleton()->invoke(5, $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, 'civicrm_post_case_merge'); + return self::singleton()->invoke(5, $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self::$_nullObject, 'civicrm_post_case_merge'); } /** @@ -1622,4 +1680,52 @@ abstract class CRM_Utils_Hook { ); } + /** + * This hook fires whenever a record in a case changes. + * + * @param \Civi\CCase\Analyzer $analyzer + */ + static function caseChange(\Civi\CCase\Analyzer $analyzer) { + $event = new \Civi\CCase\Event\CaseChangeEvent($analyzer); + \Civi\Core\Container::singleton()->get('dispatcher')->dispatch("hook_civicrm_caseChange", $event); + + return self::singleton()->invoke(1, $angularModules, + self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, + 'civicrm_caseChange' + ); + } + + /** + * Generate a default CRUD URL for an entity + * + * @param array $spec with keys: + * - action: int, eg CRM_Core_Action::VIEW or CRM_Core_Action::UPDATE + * - entity_table: string + * - entity_id: int + * @param CRM_Core_DAO $bao + * @param array $link to define the link, add these keys to $link: + * - title: string + * - path: string + * - query: array + * - url: string (used in lieu of "path"/"query") + * Note: if making "url" CRM_Utils_System::url(), set $htmlize=false + * @return mixed + */ + static function crudLink($spec, $bao, &$link) { + return self::singleton()->invoke(3, $spec, $bao, $link, + self::$_nullObject, self::$_nullObject, self::$_nullObject, + 'civicrm_crudLink' + ); + } + + /** + * @param array $fileSearches + * @return mixed + */ + static function fileSearches(&$fileSearches) { + return self::singleton()->invoke(1, $fileSearches, + self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, + 'civicrm_fileSearches' + ); + } }