3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
14 * @package CiviCRM_Hook
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 abstract class CRM_Utils_Hook
{
19 // Allowed values for dashboard hook content placement
20 // Default - place content below activity list
21 const DASHBOARD_BELOW
= 1;
22 // Place content above activity list
23 const DASHBOARD_ABOVE
= 2;
24 // Don't display activity list at all
25 const DASHBOARD_REPLACE
= 3;
27 // by default - place content below existing content
28 const SUMMARY_BELOW
= 1;
29 // place hook content above
30 const SUMMARY_ABOVE
= 2;
32 *create your own summaries
34 const SUMMARY_REPLACE
= 3;
37 * Object to pass when an object is required to be passed by params.
39 * This is supposed to be a convenience but note that it is a bad
40 * pattern as it can get contaminated & result in hard-to-diagnose bugs.
44 public static $_nullObject = NULL;
47 * We only need one instance of this object. So we use the singleton
48 * pattern and cache the instance in this variable
52 static private $_singleton = NULL;
57 private $commonIncluded = FALSE;
62 private $commonCiviModules = [];
65 * @var CRM_Utils_Cache_Interface
70 * Constructor and getter for the singleton instance.
74 * @return CRM_Utils_Hook
75 * An instance of $config->userHookClass
77 public static function singleton($fresh = FALSE) {
78 if (self
::$_singleton == NULL ||
$fresh) {
79 $config = CRM_Core_Config
::singleton();
80 $class = $config->userHookClass
;
81 self
::$_singleton = new $class();
83 return self
::$_singleton;
87 * CRM_Utils_Hook constructor.
89 * @throws \CRM_Core_Exception
91 public function __construct() {
92 $this->cache
= CRM_Utils_Cache
::create([
94 'type' => ['ArrayCache'],
100 * Invoke a hook through the UF/CMS hook system and the extension-hook
103 * @param int $numParams
104 * Number of parameters to pass to the hook.
106 * Parameter to be passed to the hook.
108 * Parameter to be passed to the hook.
110 * Parameter to be passed to the hook.
112 * Parameter to be passed to the hook.
114 * Parameter to be passed to the hook.
116 * Parameter to be passed to the hook.
117 * @param string $fnSuffix
118 * Function suffix, this is effectively the hook name.
122 abstract public function invokeViaUF(
124 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
131 * This is a transitional adapter. It supports the legacy syntax
132 * but also accepts enough information to support Symfony Event
135 * @param array $names
136 * (Recommended) Array of parameter names, in order.
137 * Using an array is recommended because it enables full
138 * event-broadcasting behaviors.
139 * (Legacy) Number of parameters to pass to the hook.
140 * This is provided for transitional purposes.
147 * @param mixed $fnSuffix
150 public function invoke(
152 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
155 if (!is_array($names)) {
156 // We were called with the old contract wherein $names is actually an int.
157 // Symfony dispatcher requires some kind of name.
158 Civi
::log()->warning("hook_$fnSuffix should be updated to pass an array of parameter names to CRM_Utils_Hook::invoke().", ['civi.tag' => 'deprecated']);
159 $compatNames = ['arg1', 'arg2', 'arg3', 'arg4', 'arg5', 'arg6'];
160 $names = array_slice($compatNames, 0, (int) $names);
163 $event = \Civi\Core\Event\GenericHookEvent
::createOrdered(
165 [&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6]
167 \Civi
::dispatcher()->dispatch('hook_' . $fnSuffix, $event);
168 return $event->getReturnValues();
172 * @param array $numParams
184 public function commonInvoke(
186 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
190 $this->commonBuildModuleList($fnPrefix);
192 return $this->runHooks($this->commonCiviModules
, $fnSuffix,
193 $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6
198 * Build the list of modules to be processed for hooks.
200 * @param string $fnPrefix
202 public function commonBuildModuleList($fnPrefix) {
203 if (!$this->commonIncluded
) {
204 // include external file
205 $this->commonIncluded
= TRUE;
207 $config = CRM_Core_Config
::singleton();
208 if (!empty($config->customPHPPathDir
)) {
209 $civicrmHooksFile = CRM_Utils_File
::addTrailingSlash($config->customPHPPathDir
) . 'civicrmHooks.php';
210 if (file_exists($civicrmHooksFile)) {
211 @include_once
$civicrmHooksFile;
215 if (!empty($fnPrefix)) {
216 $this->commonCiviModules
[$fnPrefix] = $fnPrefix;
219 $this->requireCiviModules($this->commonCiviModules
);
226 * @param array $civiModules
227 * @param string $fnSuffix
228 * @param int $numParams
237 * @throws \CRM_Core_Exception
239 public function runHooks(
240 $civiModules, $fnSuffix, $numParams,
241 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6
243 // $civiModules is *not* passed by reference because runHooks
244 // must be reentrant. PHP is finicky about running
245 // multiple loops over the same variable. The circumstances
246 // to reproduce the issue are pretty intricate.
249 $fnNames = $this->cache
->get($fnSuffix);
250 if (!is_array($fnNames)) {
252 if ($civiModules !== NULL) {
253 foreach ($civiModules as $module) {
254 $fnName = "{$module}_{$fnSuffix}";
255 if (function_exists($fnName)) {
256 $fnNames[] = $fnName;
259 $this->cache
->set($fnSuffix, $fnNames);
263 foreach ($fnNames as $fnName) {
265 switch ($numParams) {
267 $fResult = $fnName();
271 $fResult = $fnName($arg1);
275 $fResult = $fnName($arg1, $arg2);
279 $fResult = $fnName($arg1, $arg2, $arg3);
283 $fResult = $fnName($arg1, $arg2, $arg3, $arg4);
287 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5);
291 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
295 throw new CRM_Core_Exception(ts('Invalid hook invocation'));
298 if (!empty($fResult) &&
301 $result = array_merge($result, $fResult);
305 return empty($result) ?
TRUE : $result;
311 public function requireCiviModules(&$moduleList) {
312 $civiModules = CRM_Core_PseudoConstant
::getModuleExtensions();
313 foreach ($civiModules as $civiModule) {
314 if (!file_exists($civiModule['filePath'])) {
315 CRM_Core_Session
::setStatus(
316 ts('Error loading module file (%1). Please restore the file or disable the module.',
317 [1 => $civiModule['filePath']]),
318 ts('Warning'), 'error');
321 include_once $civiModule['filePath'];
322 $moduleList[$civiModule['prefix']] = $civiModule['prefix'];
327 * This hook is called before a db write on some core objects.
328 * This hook does not allow the abort of the operation
331 * The type of operation being performed.
332 * @param string $objectName
333 * The name of the object.
335 * The object id if available.
336 * @param array $params
337 * The parameters used for object creation / editing.
340 * the return value is ignored
342 public static function pre($op, $objectName, $id, &$params = []) {
343 $event = new \Civi\Core\Event\
PreEvent($op, $objectName, $id, $params);
344 \Civi
::dispatcher()->dispatch('hook_civicrm_pre', $event);
345 return $event->getReturnValues();
349 * This hook is called after a db write on some core objects.
352 * The type of operation being performed.
353 * @param string $objectName
354 * The name of the object.
355 * @param int $objectId
356 * The unique identifier for the object.
357 * @param object $objectRef
358 * The reference to the object if available.
361 * based on op. pre-hooks return a boolean or
362 * an error message which aborts the operation
364 public static function post($op, $objectName, $objectId, &$objectRef = NULL) {
365 $event = new \Civi\Core\Event\
PostEvent($op, $objectName, $objectId, $objectRef);
366 \Civi
::dispatcher()->dispatch('hook_civicrm_post', $event);
367 return $event->getReturnValues();
371 * This hook is equivalent to post(), except that it is guaranteed to run
372 * outside of any SQL transaction. The objectRef is not modifiable.
374 * This hook is defined for two cases:
376 * 1. If the original action runs within a transaction, then the hook fires
377 * after the transaction commits.
378 * 2. If the original action runs outside a transaction, then the data was
379 * committed immediately, and we can run the hook immediately.
382 * The type of operation being performed.
383 * @param string $objectName
384 * The name of the object.
385 * @param int $objectId
386 * The unique identifier for the object.
387 * @param object $objectRef
388 * The reference to the object if available.
391 * based on op. pre-hooks return a boolean or
392 * an error message which aborts the operation
394 public static function postCommit($op, $objectName, $objectId, $objectRef = NULL) {
395 $event = new \Civi\Core\Event\
PostEvent($op, $objectName, $objectId, $objectRef);
396 \Civi
::dispatcher()->dispatch('hook_civicrm_postCommit', $event);
397 return $event->getReturnValues();
401 * This hook retrieves links from other modules and injects it into.
402 * the view contact tabs
405 * The type of operation being performed.
406 * @param string $objectName
407 * The name of the object.
408 * @param int $objectId
409 * The unique identifier for the object.
410 * @param array $links
411 * (optional) the links array (introduced in v3.2).
413 * (optional) the bitmask to show/hide links.
414 * @param array $values
415 * (optional) the values to fill the links.
418 * the return value is ignored
420 public static function links($op, $objectName, &$objectId, &$links, &$mask = NULL, &$values = []) {
421 return self
::singleton()->invoke(['op', 'objectName', 'objectId', 'links', 'mask', 'values'], $op, $objectName, $objectId, $links, $mask, $values, 'civicrm_links');
425 * Alter the contents of a resource bundle (ie a collection of JS/CSS/etc).
427 * TIP: $bundle->add*() and $bundle->filter() should be useful for
428 * adding/removing/updating items.
430 * @param CRM_Core_Resources_Bundle $bundle
432 * @see CRM_Core_Resources_CollectionInterface::add()
433 * @see CRM_Core_Resources_CollectionInterface::filter()
435 public static function alterBundle($bundle) {
436 return self
::singleton()
437 ->invoke(['bundle'], $bundle, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBundle');
441 * This hook is invoked during the CiviCRM form preProcess phase.
443 * @param string $formName
444 * The name of the form.
445 * @param CRM_Core_Form $form
446 * Reference to the form object.
449 * the return value is ignored
451 public static function preProcess($formName, &$form) {
452 return self
::singleton()
453 ->invoke(['formName', 'form'], $formName, $form, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_preProcess');
457 * This hook is invoked when building a CiviCRM form. This hook should also
458 * be used to set the default values of a form element
460 * @param string $formName
461 * The name of the form.
462 * @param CRM_Core_Form $form
463 * Reference to the form object.
466 * the return value is ignored
468 public static function buildForm($formName, &$form) {
469 return self
::singleton()->invoke(['formName', 'form'], $formName, $form,
470 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
476 * This hook is invoked when a CiviCRM form is submitted. If the module has injected
477 * any form elements, this hook should save the values in the database
479 * @param string $formName
480 * The name of the form.
481 * @param CRM_Core_Form $form
482 * Reference to the form object.
485 * the return value is ignored
487 public static function postProcess($formName, &$form) {
488 return self
::singleton()->invoke(['formName', 'form'], $formName, $form,
489 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
490 'civicrm_postProcess'
495 * This hook is invoked during all CiviCRM form validation. An array of errors
496 * detected is returned. Else we assume validation succeeded.
498 * @param string $formName
499 * The name of the form.
500 * @param array &$fields the POST parameters as filtered by QF
501 * @param array &$files the FILES parameters as sent in by POST
502 * @param array &$form the form object
503 * @param array &$errors the array of errors.
506 * formRule hooks return a boolean or
507 * an array of error messages which display a QF Error
509 public static function validateForm($formName, &$fields, &$files, &$form, &$errors) {
510 return self
::singleton()
511 ->invoke(['formName', 'fields', 'files', 'form', 'errors'],
512 $formName, $fields, $files, $form, $errors, self
::$_nullObject, 'civicrm_validateForm');
516 * This hook is called after a db write on a custom table.
519 * The type of operation being performed.
520 * @param string $groupID
521 * The custom group ID.
522 * @param object $entityID
523 * The entityID of the row in the custom table.
524 * @param array $params
525 * The parameters that were sent into the calling function.
528 * the return value is ignored
530 public static function custom($op, $groupID, $entityID, &$params) {
531 return self
::singleton()
532 ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_custom');
536 * This hook is called before a db write on a custom table.
539 * The type of operation being performed.
540 * @param string $groupID
541 * The custom group ID.
542 * @param object $entityID
543 * The entityID of the row in the custom table.
544 * @param array $params
545 * The parameters that were sent into the calling function.
548 * the return value is ignored
550 public static function customPre($op, $groupID, $entityID, &$params) {
551 return self
::singleton()
552 ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_customPre');
556 * This hook is called when composing the ACL where clause to restrict
557 * visibility of contacts to the logged in user
560 * The type of permission needed.
561 * @param array $tables
562 * (reference ) add the tables that are needed for the select clause.
563 * @param array $whereTables
564 * (reference ) add the tables that are needed for the where clause.
565 * @param int $contactID
566 * The contactID for whom the check is made.
567 * @param string $where
568 * The currrent where clause.
571 * the return value is ignored
573 public static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) {
574 return self
::singleton()
575 ->invoke(['type', 'tables', 'whereTables', 'contactID', 'where'], $type, $tables, $whereTables, $contactID, $where, self
::$_nullObject, 'civicrm_aclWhereClause');
579 * This hook is called when composing the ACL where clause to restrict
580 * visibility of contacts to the logged in user
583 * The type of permission needed.
584 * @param int $contactID
585 * The contactID for whom the check is made.
586 * @param string $tableName
587 * The tableName which is being permissioned.
588 * @param array $allGroups
589 * The set of all the objects for the above table.
590 * @param array $currentGroups
591 * The set of objects that are currently permissioned for this contact.
594 * the return value is ignored
596 public static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) {
597 return self
::singleton()
598 ->invoke(['type', 'contactID', 'tableName', 'allGroups', 'currentGroups'], $type, $contactID, $tableName, $allGroups, $currentGroups, self
::$_nullObject, 'civicrm_aclGroup');
602 * @param string|CRM_Core_DAO $entity
603 * @param array $clauses
606 public static function selectWhereClause($entity, &$clauses) {
607 $entityName = is_object($entity) ?
_civicrm_api_get_entity_name_from_dao($entity) : $entity;
608 return self
::singleton()->invoke(['entity', 'clauses'], $entityName, $clauses,
609 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
610 'civicrm_selectWhereClause'
615 * This hook is called when building the menu table.
617 * @param array $files
618 * The current set of files to process.
621 * the return value is ignored
623 public static function xmlMenu(&$files) {
624 return self
::singleton()->invoke(['files'], $files,
625 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
631 * (Experimental) This hook is called when build the menu table.
633 * @param array $items
634 * List of records to include in menu table.
636 * the return value is ignored
638 public static function alterMenu(&$items) {
639 return self
::singleton()->invoke(['items'], $items,
640 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
646 * A theme is a set of CSS files which are loaded on CiviCRM pages. To register a new
647 * theme, add it to the $themes array. Use these properties:
649 * - ext: string (required)
650 * The full name of the extension which defines the theme.
651 * Ex: "org.civicrm.themes.greenwich".
652 * - title: string (required)
654 * - help: string (optional)
655 * Description of the theme's appearance.
656 * - url_callback: mixed (optional)
657 * A function ($themes, $themeKey, $cssExt, $cssFile) which returns the URL(s) for a CSS resource.
658 * Returns either an array of URLs or PASSTHRU.
659 * Ex: \Civi\Core\Themes\Resolvers::simple (default)
660 * Ex: \Civi\Core\Themes\Resolvers::none
661 * - prefix: string (optional)
662 * A prefix within the extension folder to prepend to the file name.
663 * - search_order: array (optional)
664 * A list of themes to search.
665 * Generally, the last theme should be "*fallback*" (Civi\Core\Themes::FALLBACK).
666 * - excludes: array (optional)
667 * A list of files (eg "civicrm:css/bootstrap.css" or "$ext:$file") which should never
668 * be returned (they are excluded from display).
670 * @param array $themes
671 * List of themes, keyed by name.
673 * the return value is ignored
675 public static function themes(&$themes) {
676 return self
::singleton()->invoke(['themes'], $themes,
677 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
683 * The activeTheme hook determines which theme is active.
685 * @param string $theme
686 * The identifier for the theme. Alterable.
688 * @param array $context
689 * Information about the current page-request. Includes some mix of:
690 * - page: the relative path of the current Civi page (Ex: 'civicrm/dashboard').
691 * - themes: an instance of the Civi\Core\Themes service.
693 * the return value is ignored
695 public static function activeTheme(&$theme, $context) {
696 return self
::singleton()->invoke(['theme', 'context'], $theme, $context,
697 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
698 'civicrm_activeTheme'
703 * This hook is called for declaring managed entities via API.
705 * @param array $entities
706 * List of pending entities. Each entity is an array with keys:
707 * + 'module': string; for module-extensions, this is the fully-qualifed name (e.g. "com.example.mymodule"); for CMS modules, the name is prefixed by the CMS (e.g. "drupal.mymodule")
708 * + 'name': string, a symbolic name which can be used to track this entity (Note: Each module creates its own namespace)
709 * + 'entity': string, an entity-type supported by the CiviCRM API (Note: this currently must be an entity which supports the 'is_active' property)
710 * + 'params': array, the entity data as supported by the CiviCRM API
711 * + 'update' (v4.5+): string, a policy which describes when to update records
712 * - 'always' (default): always update the managed-entity record; changes in $entities will override any local changes (eg by the site-admin)
713 * - 'never': never update the managed-entity record; changes made locally (eg by the site-admin) will override changes in $entities
714 * + 'cleanup' (v4.5+): string, a policy which describes whether to cleanup the record when it becomes orphaned (ie when $entities no longer references the record)
715 * - 'always' (default): always delete orphaned records
716 * - 'never': never delete orphaned records
717 * - 'unused': only delete orphaned records if there are no other references to it in the DB. (This is determined by calling the API's "getrefcount" action.)
720 * the return value is ignored
722 public static function managed(&$entities) {
723 return self
::singleton()->invoke(['entities'], $entities,
724 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
730 * This hook is called when rendering the dashboard (q=civicrm/dashboard)
732 * @param int $contactID
733 * The contactID for whom the dashboard is being rendered.
734 * @param int $contentPlacement
735 * (output parameter) where should the hook content be displayed.
736 * relative to the activity list
739 * the html snippet to include in the dashboard
741 public static function dashboard($contactID, &$contentPlacement = self
::DASHBOARD_BELOW
) {
742 $retval = self
::singleton()->invoke(['contactID', 'contentPlacement'], $contactID, $contentPlacement,
743 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
748 * Note we need this seemingly unnecessary code because in the event that the implementation
749 * of the hook declares the second parameter but doesn't set it, then it comes back unset even
750 * though we have a default value in this function's declaration above.
752 if (!isset($contentPlacement)) {
753 $contentPlacement = self
::DASHBOARD_BELOW
;
760 * This hook is called before storing recently viewed items.
762 * @param array $recentArray
763 * An array of recently viewed or processed items, for in place modification.
767 public static function recent(&$recentArray) {
768 return self
::singleton()->invoke(['recentArray'], $recentArray,
769 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
775 * Determine how many other records refer to a given record.
777 * @param CRM_Core_DAO $dao
778 * The item for which we want a reference count.
779 * @param array $refCounts
780 * Each item in the array is an Array with keys:
781 * - name: string, eg "sql:civicrm_email:contact_id"
782 * - type: string, eg "sql"
783 * - count: int, eg "5" if there are 5 email addresses that refer to $dao
786 * Return is not really intended to be used.
788 public static function referenceCounts($dao, &$refCounts) {
789 return self
::singleton()->invoke(['dao', 'refCounts'], $dao, $refCounts,
790 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
791 'civicrm_referenceCounts'
796 * This hook is called when building the amount structure for a Contribution or Event Page.
798 * @param int $pageType
799 * Is this a contribution or event page.
800 * @param CRM_Core_Form $form
801 * Reference to the form object.
802 * @param array $amount
803 * The amount structure to be displayed.
807 public static function buildAmount($pageType, &$form, &$amount) {
808 return self
::singleton()->invoke(['pageType', 'form', 'amount'], $pageType, $form, $amount, self
::$_nullObject,
809 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildAmount');
813 * This hook is called when building the state list for a particular country.
815 * @param array $countryID
816 * The country id whose states are being selected.
821 public static function buildStateProvinceForCountry($countryID, &$states) {
822 return self
::singleton()->invoke(['countryID', 'states'], $countryID, $states,
823 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
824 'civicrm_buildStateProvinceForCountry'
829 * This hook is called when rendering the tabs used for events and potentially
830 * contribution pages, etc.
832 * @param string $tabsetName
833 * Name of the screen or visual element.
835 * Tabs that will be displayed.
836 * @param array $context
837 * Extra data about the screen or context in which the tab is used.
841 public static function tabset($tabsetName, &$tabs, $context) {
842 return self
::singleton()->invoke(['tabsetName', 'tabs', 'context'], $tabsetName, $tabs,
843 $context, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabset'
848 * This hook is called when sending an email / printing labels
850 * @param array $tokens
851 * The list of tokens that can be used for the contact.
855 public static function tokens(&$tokens) {
856 return self
::singleton()->invoke(['tokens'], $tokens,
857 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tokens'
862 * This hook allows modification of the admin panels
864 * @param array $panels
865 * Associated array of admin panels
869 public static function alterAdminPanel(&$panels) {
870 return self
::singleton()->invoke(['panels'], $panels,
871 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
872 'civicrm_alterAdminPanel'
877 * This hook is called when sending an email / printing labels to get the values for all the
878 * tokens returned by the 'tokens' hook
880 * @param array $details
881 * The array to store the token values indexed by contactIDs.
882 * @param array $contactIDs
883 * An array of contactIDs.
885 * The jobID if this is associated with a CiviMail mailing.
886 * @param array $tokens
887 * The list of tokens associated with the content.
888 * @param string $className
889 * The top level className from where the hook is invoked.
893 public static function tokenValues(
900 return self
::singleton()
901 ->invoke(['details', 'contactIDs', 'jobID', 'tokens', 'className'], $details, $contactIDs, $jobID, $tokens, $className, self
::$_nullObject, 'civicrm_tokenValues');
905 * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables
908 * @param object $page
909 * The page that will be rendered.
913 public static function pageRun(&$page) {
914 return self
::singleton()->invoke(['page'], $page,
915 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
921 * This hook is called after a copy of an object has been made. The current objects are
922 * Event, Contribution Page and UFGroup
924 * @param string $objectName
925 * Name of the object.
926 * @param object $object
927 * Reference to the copy.
931 public static function copy($objectName, &$object) {
932 return self
::singleton()->invoke(['objectName', 'object'], $objectName, $object,
933 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
939 * This hook is called when a contact unsubscribes from a mailing. It allows modules
940 * to override what the contacts are removed from.
944 * @param int $mailingId
945 * The id of the mailing to unsub from
946 * @param int $contactId
947 * The id of the contact who is unsubscribing
948 * @param array|int $groups
949 * Groups the contact will be removed from.
950 * @param array|int $baseGroups
951 * Base groups (used in smart mailings) the contact will be removed from.
956 public static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) {
957 return self
::singleton()
958 ->invoke(['op', 'mailingId', 'contactId', 'groups', 'baseGroups'], $op, $mailingId, $contactId, $groups, $baseGroups, self
::$_nullObject, 'civicrm_unsubscribeGroups');
962 * This hook is called when CiviCRM needs to edit/display a custom field with options
964 * @deprecated in favor of hook_civicrm_fieldOptions
966 * @param int $customFieldID
967 * The custom field ID.
968 * @param array $options
969 * The current set of options for that custom field.
970 * You can add/remove existing options.
971 * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important
972 * to be careful to not overwrite the array.
973 * Only add/edit/remove the specific field options you intend to affect.
974 * @param bool $detailedFormat
975 * If true, the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format
976 * @param array $selectAttributes
977 * Contain select attribute(s) if any.
981 public static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE, $selectAttributes = []) {
982 // Weird: $selectAttributes is inputted but not outputted.
983 return self
::singleton()->invoke(['customFieldID', 'options', 'detailedFormat'], $customFieldID, $options, $detailedFormat,
984 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
985 'civicrm_customFieldOptions'
990 * Hook for modifying field options
992 * @param string $entity
993 * @param string $field
994 * @param array $options
995 * @param array $params
999 public static function fieldOptions($entity, $field, &$options, $params) {
1000 return self
::singleton()->invoke(['entity', 'field', 'options', 'params'], $entity, $field, $options, $params,
1001 self
::$_nullObject, self
::$_nullObject,
1002 'civicrm_fieldOptions'
1008 * This hook is called to display the list of actions allowed after doing a search.
1009 * This allows the module developer to inject additional actions or to remove existing actions.
1011 * @param string $objectType
1012 * The object type for this search.
1013 * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported.
1014 * @param array $tasks
1015 * The current set of tasks for that custom field.
1016 * You can add/remove existing tasks.
1017 * Each task needs to have a title (eg 'title' => ts( 'Group - add contacts')) and a class
1018 * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
1019 * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
1020 * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be
1021 * found in CRM/$objectType/Task.php.
1025 public static function searchTasks($objectType, &$tasks) {
1026 return self
::singleton()->invoke(['objectType', 'tasks'], $objectType, $tasks,
1027 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1028 'civicrm_searchTasks'
1033 * @param mixed $form
1034 * @param array $params
1038 public static function eventDiscount(&$form, &$params) {
1039 return self
::singleton()->invoke(['form', 'params'], $form, $params,
1040 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1041 'civicrm_eventDiscount'
1046 * When adding a new "Mail Account" (`MailSettings`), present a menu of setup
1049 * @param array $setupActions
1050 * Each item has a symbolic-key, and it has the properties:
1052 * - callback: string|array, the function which starts the setup process.
1053 * The function is expected to return a 'url' for the config screen.
1056 public static function mailSetupActions(&$setupActions) {
1057 return self
::singleton()->invoke(['setupActions'], $setupActions, self
::$_nullObject, self
::$_nullObject,
1058 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1059 'civicrm_mailSetupActions'
1064 * This hook is called when composing a mailing. You can include / exclude other groups as needed.
1066 * @param mixed $form
1067 * The form object for which groups / mailings being displayed
1068 * @param array $groups
1069 * The list of groups being included / excluded
1070 * @param array $mailings
1071 * The list of mailings being included / excluded
1075 public static function mailingGroups(&$form, &$groups, &$mailings) {
1076 return self
::singleton()->invoke(['form', 'groups', 'mailings'], $form, $groups, $mailings,
1077 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1078 'civicrm_mailingGroups'
1083 * (Experimental) Modify the list of template-types used for CiviMail composition.
1085 * @param array $types
1086 * Sequentially indexed list of template types. Each type specifies:
1088 * - editorUrl: string, Angular template URL
1089 * - weight: int, priority when picking a default value for new mailings
1092 public static function mailingTemplateTypes(&$types) {
1093 return self
::singleton()->invoke(['types'], $types, self
::$_nullObject, self
::$_nullObject,
1094 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1095 'civicrm_mailingTemplateTypes'
1100 * This hook is called when composing the array of membershipTypes and their cost during a membership registration
1102 * Note the hook is called on initial page load and also reloaded after submit (PRG pattern).
1103 * You can use it to alter the membership types when first loaded, or after submission
1104 * (for example if you want to gather data in the form and use it to alter the fees).
1106 * @param mixed $form
1107 * The form object that is presenting the page
1108 * @param array $membershipTypes
1109 * The array of membership types and their amount
1113 public static function membershipTypeValues(&$form, &$membershipTypes) {
1114 return self
::singleton()->invoke(['form', 'membershipTypes'], $form, $membershipTypes,
1115 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1116 'civicrm_membershipTypeValues'
1121 * This hook is called when rendering the contact summary.
1123 * @param int $contactID
1124 * The contactID for whom the summary is being rendered
1125 * @param mixed $content
1126 * @param int $contentPlacement
1127 * Specifies where the hook content should be displayed relative to the
1131 * The html snippet to include in the contact summary
1133 public static function summary($contactID, &$content, &$contentPlacement = self
::SUMMARY_BELOW
) {
1134 return self
::singleton()->invoke(['contactID', 'content', 'contentPlacement'], $contactID, $content, $contentPlacement,
1135 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1141 * Use this hook to populate the list of contacts returned by Contact Reference custom fields.
1142 * By default, Contact Reference fields will search on and return all CiviCRM contacts.
1143 * If you want to limit the contacts returned to a specific group, or some other criteria
1144 * - you can override that behavior by providing a SQL query that returns some subset of your contacts.
1145 * The hook is called when the query is executed to get the list of contacts to display.
1147 * @param mixed $query
1148 * - the query that will be executed (input and output parameter);.
1149 * It's important to realize that the ACL clause is built prior to this hook being fired,
1150 * so your query will ignore any ACL rules that may be defined.
1151 * Your query must return two columns:
1152 * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data')
1154 * @param string $queryText
1155 * The name string to execute the query against (this is the value being typed in by the user).
1156 * @param string $context
1157 * The context in which this ajax call is being made (for example: 'customfield', 'caseview').
1159 * The id of the object for which the call is being made.
1160 * For custom fields, it will be the custom field id
1164 public static function contactListQuery(&$query, $queryText, $context, $id) {
1165 return self
::singleton()->invoke(['query', 'queryText', 'context', 'id'], $query, $queryText, $context, $id,
1166 self
::$_nullObject, self
::$_nullObject,
1167 'civicrm_contactListQuery'
1172 * Hook definition for altering payment parameters before talking to a payment processor back end.
1174 * Definition will look like this:
1176 * function hook_civicrm_alterPaymentProcessorParams(
1182 * @param CRM_Core_Payment $paymentObj
1183 * Instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy')
1184 * See discussion in CRM-16224 as to whether $paymentObj should be passed by reference.
1185 * @param array &$rawParams
1186 * array of params as passed to to the processor
1187 * @param array|\Civi\Payment\PropertyBag &$cookedParams
1188 * params after the processor code has translated them into its own key/value pairs
1191 * This return is not really intended to be used.
1193 public static function alterPaymentProcessorParams(
1198 return self
::singleton()->invoke(['paymentObj', 'rawParams', 'cookedParams'], $paymentObj, $rawParams, $cookedParams,
1199 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1200 'civicrm_alterPaymentProcessorParams'
1205 * This hook is called when an email is about to be sent by CiviCRM.
1207 * @param array $params
1208 * Array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html,
1209 * returnPath, replyTo, headers, attachments (array)
1210 * @param string $context
1211 * The context in which the hook is being invoked, eg 'civimail'.
1215 public static function alterMailParams(&$params, $context = NULL) {
1216 return self
::singleton()->invoke(['params', 'context'], $params, $context,
1217 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1218 'civicrm_alterMailParams'
1223 * This hook is called when loading a mail-store (e.g. IMAP, POP3, or Maildir).
1225 * @param array $params
1226 * Most fields correspond to data in the MailSettings entity:
1229 * - username: string
1230 * - password: string
1233 * - local_part: string
1235 * With a few supplements
1236 * - protocol: string, symbolic protocol name (e.g. "IMAP")
1237 * - factory: callable, the function which instantiates the driver class
1238 * - auth: string, (for some drivers) specify the authentication method (eg "Password" or "XOAuth2")
1242 public static function alterMailStore(&$params) {
1243 return self
::singleton()->invoke(['params'], $params, $context,
1244 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1245 'civicrm_alterMailStore'
1250 * This hook is called when membership status is being calculated.
1252 * @param array $membershipStatus
1253 * Membership status details as determined - alter if required.
1254 * @param array $arguments
1255 * Arguments passed in to calculate date.
1260 * - 'exclude_is_admin'
1261 * - 'membership_type_id'
1262 * @param array $membership
1263 * Membership details from the calling function.
1267 public static function alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) {
1268 return self
::singleton()->invoke(['membershipStatus', 'arguments', 'membership'], $membershipStatus, $arguments,
1269 $membership, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1270 'civicrm_alterCalculatedMembershipStatus'
1275 * This hook is called after getting the content of the mail and before tokenizing it.
1277 * @param array $content
1278 * Array fields include: html, text, subject
1282 public static function alterMailContent(&$content) {
1283 return self
::singleton()->invoke(['content'], $content,
1284 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1285 'civicrm_alterMailContent'
1290 * This hook is called when rendering the Manage Case screen.
1292 * @param int $caseID
1296 * Array of data to be displayed, where the key is a unique id to be used for styling (div id's)
1297 * and the value is an array with keys 'label' and 'value' specifying label/value pairs
1299 public static function caseSummary($caseID) {
1300 return self
::singleton()->invoke(['caseID'], $caseID,
1301 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1302 'civicrm_caseSummary'
1307 * This hook is called when locating CiviCase types.
1309 * @param array $caseTypes
1313 public static function caseTypes(&$caseTypes) {
1314 return self
::singleton()
1315 ->invoke(['caseTypes'], $caseTypes, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_caseTypes');
1319 * This hook is called when getting case email subject patterns.
1321 * All emails related to cases have case hash/id in the subject, e.g:
1322 * [case #ab12efg] Magic moment
1323 * [case #1234] Magic is here
1325 * Using this hook you can replace/enrich default list with some other
1326 * patterns, e.g. include case type categories (see CiviCase extension) like:
1327 * [(case|project|policy initiative) #hash]
1328 * [(case|project|policy initiative) #id]
1330 * @param array $subjectPatterns
1331 * Cases related email subject regexp patterns.
1335 public static function caseEmailSubjectPatterns(&$subjectPatterns) {
1336 return self
::singleton()
1337 ->invoke(['caseEmailSubjectPatterns'], $subjectPatterns, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_caseEmailSubjectPatterns');
1341 * This hook is called soon after the CRM_Core_Config object has ben initialized.
1342 * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically.
1344 * @param CRM_Core_Config|array $config
1349 public static function config(&$config) {
1350 return self
::singleton()->invoke(['config'], $config,
1351 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1357 * This hooks allows to change option values.
1359 * @deprecated in favor of hook_civicrm_fieldOptions
1361 * @param array $options
1362 * Associated array of option values / id
1363 * @param string $groupName
1368 public static function optionValues(&$options, $groupName) {
1369 return self
::singleton()->invoke(['options', 'groupName'], $options, $groupName,
1370 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1371 'civicrm_optionValues'
1376 * This hook allows modification of the navigation menu.
1378 * @param array $params
1379 * Associated array of navigation menu entry to Modify/Add
1383 public static function navigationMenu(&$params) {
1384 return self
::singleton()->invoke(['params'], $params,
1385 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1386 'civicrm_navigationMenu'
1391 * This hook allows modification of the data used to perform merging of duplicates.
1393 * @param string $type
1394 * The type of data being passed (cidRefs|eidRefs|relTables|sqls).
1395 * @param array $data
1396 * The data, as described in $type.
1397 * @param int $mainId
1398 * Contact_id of the contact that survives the merge.
1399 * @param int $otherId
1400 * Contact_id of the contact that will be absorbed and deleted.
1401 * @param array $tables
1402 * When $type is "sqls", an array of tables as it may have been handed to the calling function.
1406 public static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) {
1407 return self
::singleton()->invoke(['type', 'data', 'mainId', 'otherId', 'tables'], $type, $data, $mainId, $otherId, $tables, self
::$_nullObject, 'civicrm_merge');
1411 * This hook allows modification of the data calculated for merging locations.
1413 * @param array $blocksDAO
1414 * Array of location DAO to be saved. These are arrays in 2 keys 'update' & 'delete'.
1415 * @param int $mainId
1416 * Contact_id of the contact that survives the merge.
1417 * @param int $otherId
1418 * Contact_id of the contact that will be absorbed and deleted.
1419 * @param array $migrationInfo
1420 * Calculated migration info, informational only.
1424 public static function alterLocationMergeData(&$blocksDAO, $mainId, $otherId, $migrationInfo) {
1425 return self
::singleton()->invoke(['blocksDAO', 'mainId', 'otherId', 'migrationInfo'], $blocksDAO, $mainId, $otherId, $migrationInfo, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterLocationMergeData');
1429 * This hook provides a way to override the default privacy behavior for notes.
1431 * @param array &$noteValues
1432 * Associative array of values for this note
1436 public static function notePrivacy(&$noteValues) {
1437 return self
::singleton()->invoke(['noteValues'], $noteValues,
1438 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1439 'civicrm_notePrivacy'
1444 * This hook is called before record is exported as CSV.
1446 * @param string $exportTempTable
1447 * Name of the temporary export table used during export.
1448 * @param array $headerRows
1449 * Header rows for output.
1450 * @param array $sqlColumns
1452 * @param int $exportMode
1453 * Export mode ( contact, contribution, etc...).
1454 * @param string $componentTable
1455 * Name of temporary table
1457 * Array of object's ids
1461 public static function export(&$exportTempTable, &$headerRows, &$sqlColumns, $exportMode, $componentTable, $ids) {
1462 return self
::singleton()->invoke(['exportTempTable', 'headerRows', 'sqlColumns', 'exportMode', 'componentTable', 'ids'],
1463 $exportTempTable, $headerRows, $sqlColumns,
1464 $exportMode, $componentTable, $ids,
1470 * This hook allows modification of the queries constructed from dupe rules.
1472 * @param string $obj
1473 * Object of rulegroup class.
1474 * @param string $type
1475 * Type of queries e.g table / threshold.
1476 * @param array $query
1481 public static function dupeQuery($obj, $type, &$query) {
1482 return self
::singleton()->invoke(['obj', 'type', 'query'], $obj, $type, $query,
1483 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1489 * Check for duplicate contacts
1491 * @param array $dedupeParams
1492 * Array of params for finding duplicates: [
1493 * '{parameters returned by CRM_Dedupe_Finder::formatParams}
1494 * 'check_permission' => TRUE/FALSE;
1495 * 'contact_type' => $contactType;
1497 * 'rule_group_id' => $ruleGroupID;
1498 * 'excludedContactIDs' => $excludedContactIDs;
1499 * @param array $dedupeResults
1500 * Array of results ['handled' => TRUE/FALSE, 'ids' => array of IDs of duplicate contacts]
1501 * @param array $contextParams
1502 * The context if relevant, eg. ['event_id' => X]
1506 public static function findDuplicates($dedupeParams, &$dedupeResults, $contextParams) {
1507 return self
::singleton()
1508 ->invoke(['dedupeParams', 'dedupeResults', 'contextParams'], $dedupeParams, $dedupeResults, $contextParams, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_findDuplicates');
1512 * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php
1514 * @param string $type
1515 * Type of mail processed: 'activity' OR 'mailing'.
1516 * @param array &$params the params that were sent to the CiviCRM API function
1517 * @param object $mail
1518 * The mail object which is an ezcMail class.
1519 * @param array &$result the result returned by the api call
1520 * @param string $action
1521 * (optional ) the requested action to be performed if the types was 'mailing'.
1525 public static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) {
1526 return self
::singleton()
1527 ->invoke(['type', 'params', 'mail', 'result', 'action'], $type, $params, $mail, $result, $action, self
::$_nullObject, 'civicrm_emailProcessor');
1531 * This hook is called after a row has been processed and the
1532 * record (and associated records imported
1534 * @param string $object
1535 * Object being imported (for now Contact only, later Contribution, Activity,.
1536 * Participant and Member)
1537 * @param string $usage
1538 * Hook usage/location (for now process only, later mapping and others).
1539 * @param string $objectRef
1540 * Import record object.
1541 * @param array $params
1542 * Array with various key values: currently.
1543 * contactID - contact id
1544 * importID - row id in temp table
1545 * importTempTable - name of tempTable
1546 * fieldHeaders - field headers
1547 * fields - import fields
1551 public static function import($object, $usage, &$objectRef, &$params) {
1552 return self
::singleton()->invoke(['object', 'usage', 'objectRef', 'params'], $object, $usage, $objectRef, $params,
1553 self
::$_nullObject, self
::$_nullObject,
1559 * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission()
1560 * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php).
1562 * @param string $entity
1563 * The API entity (like contact).
1564 * @param string $action
1565 * The API action (like get).
1566 * @param array &$params the API parameters
1567 * @param array &$permissions the associative permissions array (probably to be altered by this hook)
1571 public static function alterAPIPermissions($entity, $action, &$params, &$permissions) {
1572 return self
::singleton()->invoke(['entity', 'action', 'params', 'permissions'], $entity, $action, $params, $permissions,
1573 self
::$_nullObject, self
::$_nullObject,
1574 'civicrm_alterAPIPermissions'
1579 * @param CRM_Core_DAO $dao
1583 public static function postSave(&$dao) {
1584 $hookName = 'civicrm_postSave_' . $dao->getTableName();
1585 return self
::singleton()->invoke(['dao'], $dao,
1586 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1592 * This hook allows user to customize context menu Actions on contact summary page.
1594 * @param array $actions
1595 * Array of all Actions in contextmenu.
1596 * @param int $contactID
1597 * ContactID for the summary page.
1601 public static function summaryActions(&$actions, $contactID = NULL) {
1602 return self
::singleton()->invoke(['actions', 'contactID'], $actions, $contactID,
1603 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1604 'civicrm_summaryActions'
1609 * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go.
1610 * This enables us hook implementors to modify both the headers and the rows
1612 * The BIGGEST drawback with this hook is that you may need to modify the result template to include your
1613 * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl
1615 * However, if you use the same number of columns, you can overwrite the existing columns with the values that
1616 * you want displayed. This is a hackish, but avoids template modification.
1618 * @param string $objectName
1619 * The component name that we are doing the search.
1620 * activity, campaign, case, contact, contribution, event, grant, membership, and pledge
1621 * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order )
1622 * @param array &$rows the list of values, an associate array with fields that are displayed for that component
1623 * @param array $selector
1624 * the selector object. Allows you access to the context of the search
1627 * modify the header and values object to pass the data you need
1629 public static function searchColumns($objectName, &$headers, &$rows, &$selector) {
1630 return self
::singleton()->invoke(['objectName', 'headers', 'rows', 'selector'], $objectName, $headers, $rows, $selector,
1631 self
::$_nullObject, self
::$_nullObject,
1632 'civicrm_searchColumns'
1637 * This hook is called when uf groups are being built for a module.
1639 * @param string $moduleName
1641 * @param array $ufGroups
1642 * Array of ufgroups for a module.
1646 public static function buildUFGroupsForModule($moduleName, &$ufGroups) {
1647 return self
::singleton()->invoke(['moduleName', 'ufGroups'], $moduleName, $ufGroups,
1648 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1649 'civicrm_buildUFGroupsForModule'
1654 * This hook is called when we are determining the contactID for a specific
1657 * @param string $email
1658 * The email address.
1659 * @param int $contactID
1660 * The contactID that matches this email address, IF it exists.
1661 * @param array $result
1662 * (reference) has two fields.
1663 * contactID - the new (or same) contactID
1664 * action - 3 possible values:
1665 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record
1666 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID
1667 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address
1671 public static function emailProcessorContact($email, $contactID, &$result) {
1672 return self
::singleton()->invoke(['email', 'contactID', 'result'], $email, $contactID, $result,
1673 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1674 'civicrm_emailProcessorContact'
1679 * Hook definition for altering the generation of Mailing Labels.
1681 * @param array $args
1682 * An array of the args in the order defined for the tcpdf multiCell api call.
1683 * with the variable names below converted into string keys (ie $w become 'w'
1684 * as the first key for $args)
1685 * float $w Width of cells. If 0, they extend up to the right margin of the page.
1686 * float $h Cell minimum height. The cell extends automatically if needed.
1687 * string $txt String to print
1688 * mixed $border Indicates if borders must be drawn around the cell block. The value can
1689 * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or
1690 * a string containing some or all of the following characters (in any order):
1691 * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
1692 * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string:
1693 * left align</li><li>C: center</li><li>R: right align</li><li>J: justification
1694 * (default value when $ishtml=false)</li></ul>
1695 * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
1696 * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0:
1697 * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul>
1698 * float $x x position in user units
1699 * float $y y position in user units
1700 * boolean $reseth if true reset the last cell height (default true).
1701 * int $stretch stretch character mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if
1702 * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if
1703 * necessary</li><li>4 = forced character spacing</li></ul>
1704 * boolean $ishtml set to true if $txt is HTML content (default = false).
1705 * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width.
1706 * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page,
1707 * or 0 for disable this feature. This feature works only when $ishtml=false.
1711 public static function alterMailingLabelParams(&$args) {
1712 return self
::singleton()->invoke(['args'], $args,
1713 self
::$_nullObject, self
::$_nullObject,
1714 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1715 'civicrm_alterMailingLabelParams'
1720 * This hooks allows alteration of generated page content.
1723 * Previously generated content.
1725 * Context of content - page or form.
1727 * The file name of the tpl.
1729 * A reference to the page or form object.
1733 public static function alterContent(&$content, $context, $tplName, &$object) {
1734 return self
::singleton()->invoke(['content', 'context', 'tplName', 'object'], $content, $context, $tplName, $object,
1735 self
::$_nullObject, self
::$_nullObject,
1736 'civicrm_alterContent'
1741 * This hooks allows alteration of the tpl file used to generate content. It differs from the
1742 * altercontent hook as the content has already been rendered through the tpl at that point
1745 * Previously generated content.
1747 * Reference to the form object.
1749 * Context of content - page or form.
1751 * Reference the file name of the tpl.
1755 public static function alterTemplateFile($formName, &$form, $context, &$tplName) {
1756 return self
::singleton()->invoke(['formName', 'form', 'context', 'tplName'], $formName, $form, $context, $tplName,
1757 self
::$_nullObject, self
::$_nullObject,
1758 'civicrm_alterTemplateFile'
1763 * This hook collects the trigger definition from all components.
1766 * @param string $tableName
1767 * (optional) the name of the table that we are interested in only.
1769 * @internal param \reference $triggerInfo to an array of trigger information
1770 * each element has 4 fields:
1771 * table - array of tableName
1772 * when - BEFORE or AFTER
1773 * event - array of eventName - INSERT OR UPDATE OR DELETE
1774 * sql - array of statements optionally terminated with a ;
1775 * a statement can use the tokes {tableName} and {eventName}
1776 * to do token replacement with the table / event. This allows
1777 * templatizing logging and other hooks
1780 public static function triggerInfo(&$info, $tableName = NULL) {
1781 return self
::singleton()->invoke(['info', 'tableName'], $info, $tableName,
1782 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1784 'civicrm_triggerInfo'
1789 * This hook allows changes to the spec of which tables to log.
1791 * @param array $logTableSpec
1795 public static function alterLogTables(&$logTableSpec) {
1796 return self
::singleton()->invoke(['logTableSpec'], $logTableSpec, $_nullObject,
1797 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1799 'civicrm_alterLogTables'
1804 * This hook is called when a module-extension is installed.
1805 * Each module will receive hook_civicrm_install during its own installation (but not during the
1806 * installation of unrelated modules).
1808 public static function install() {
1809 // Actually invoke via CRM_Extension_Manager_Module::callHook
1810 throw new \
RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__
, __FUNCTION__
));
1814 * This hook is called when a module-extension is uninstalled.
1815 * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the
1816 * uninstallation of unrelated modules).
1818 public static function uninstall() {
1819 // Actually invoke via CRM_Extension_Manager_Module::callHook
1820 throw new \
RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__
, __FUNCTION__
));
1824 * This hook is called when a module-extension is re-enabled.
1825 * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the
1826 * re-enablement of unrelated modules).
1828 public static function enable() {
1829 // Actually invoke via CRM_Extension_Manager_Module::callHook
1830 throw new \
RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__
, __FUNCTION__
));
1834 * This hook is called when a module-extension is disabled.
1835 * Each module will receive hook_civicrm_disable during its own disablement (but not during the
1836 * disablement of unrelated modules).
1838 public static function disable() {
1839 // Actually invoke via CRM_Extension_Manager_Module::callHook
1840 throw new \
RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__
, __FUNCTION__
));
1846 * This hook is called when the browser is being re-directed and allows the url
1849 * @param \Psr\Http\Message\UriInterface $url
1850 * @param array $context
1851 * Additional information about context
1852 * - output - if this is 'json' then it will return json.
1855 * the return value is ignored
1857 public static function alterRedirect(&$url, &$context) {
1858 return self
::singleton()->invoke(['url', 'context'], $url,
1859 $context, self
::$_nullObject,
1860 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1861 'civicrm_alterRedirect'
1872 public static function alterReportVar($varType, &$var, &$object) {
1873 return self
::singleton()->invoke(['varType', 'var', 'object'], $varType, $var, $object,
1875 self
::$_nullObject, self
::$_nullObject,
1876 'civicrm_alterReportVar'
1881 * This hook is called to drive database upgrades for extension-modules.
1884 * The type of operation being performed; 'check' or 'enqueue'.
1885 * @param CRM_Queue_Queue $queue
1886 * (for 'enqueue') the modifiable list of pending up upgrade tasks.
1889 * NULL, if $op is 'enqueue'.
1890 * TRUE, if $op is 'check' and upgrades are pending.
1891 * FALSE, if $op is 'check' and upgrades are not pending.
1893 public static function upgrade($op, CRM_Queue_Queue
$queue = NULL) {
1894 return self
::singleton()->invoke(['op', 'queue'], $op, $queue,
1895 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1902 * This hook is called when an email has been successfully sent by CiviCRM, but not on an error.
1904 * @param array $params
1905 * The mailing parameters. Array fields include: groupName, from, toName,
1906 * toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers,
1907 * attachments (array)
1911 public static function postEmailSend(&$params) {
1912 return self
::singleton()->invoke(['params'], $params,
1913 self
::$_nullObject, self
::$_nullObject,
1914 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1915 'civicrm_postEmailSend'
1920 * This hook is called when a CiviMail mailing has completed
1922 * @param int $mailingId
1927 public static function postMailing($mailingId) {
1928 return self
::singleton()->invoke(['mailingId'], $mailingId,
1929 self
::$_nullObject, self
::$_nullObject,
1930 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1931 'civicrm_postMailing'
1936 * This hook is called when Settings specifications are loaded.
1938 * @param array $settingsFolders
1939 * List of paths from which to derive metadata
1943 public static function alterSettingsFolders(&$settingsFolders) {
1944 return self
::singleton()->invoke(['settingsFolders'], $settingsFolders,
1945 self
::$_nullObject, self
::$_nullObject,
1946 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1947 'civicrm_alterSettingsFolders'
1952 * This hook is called when Settings have been loaded from the xml
1953 * It is an opportunity for hooks to alter the data
1955 * @param array $settingsMetaData
1956 * Settings Metadata.
1957 * @param int $domainID
1958 * @param mixed $profile
1962 public static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) {
1963 return self
::singleton()->invoke(['settingsMetaData', 'domainID', 'profile'], $settingsMetaData,
1964 $domainID, $profile,
1965 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1966 'civicrm_alterSettingsMetaData'
1971 * This hook is called before running an api call.
1973 * @param API_Wrapper[] $wrappers
1974 * (see CRM_Utils_API_ReloadOption as an example)
1975 * @param mixed $apiRequest
1978 * The return value is ignored
1980 public static function apiWrappers(&$wrappers, $apiRequest) {
1981 return self
::singleton()
1982 ->invoke(['wrappers', 'apiRequest'], $wrappers, $apiRequest, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1983 self
::$_nullObject, 'civicrm_apiWrappers'
1988 * This hook is called before running pending cron jobs.
1990 * @param CRM_Core_JobManager $jobManager
1993 * The return value is ignored.
1995 public static function cron($jobManager) {
1996 return self
::singleton()->invoke(['jobManager'],
1997 $jobManager, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2003 * This hook is called when loading CMS permissions; use this hook to modify
2004 * the array of system permissions for CiviCRM.
2006 * @param array $permissions
2007 * Array of permissions. See CRM_Core_Permission::getCorePermissions() for
2008 * the format of this array.
2011 * The return value is ignored
2013 public static function permission(&$permissions) {
2014 return self
::singleton()->invoke(['permissions'], $permissions,
2015 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2016 'civicrm_permission'
2021 * This hook is called when checking permissions; use this hook to dynamically
2022 * escalate user permissions in certain use cases (cf. CRM-19256).
2024 * @param string $permission
2025 * The name of an atomic permission, ie. 'access deleted contacts'
2026 * @param bool $granted
2027 * Whether this permission is currently granted. The hook can change this value.
2028 * @param int $contactId
2029 * Contact whose permissions we are checking (if null, assume current user).
2032 * The return value is ignored
2034 public static function permission_check($permission, &$granted, $contactId) {
2035 return self
::singleton()->invoke(['permission', 'granted', 'contactId'], $permission, $granted, $contactId,
2036 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2037 'civicrm_permission_check'
2042 * @param CRM_Core_Exception $exception
2043 * @param mixed $request
2044 * Reserved for future use.
2046 public static function unhandledException($exception, $request = NULL) {
2047 $event = new \Civi\Core\Event\
UnhandledExceptionEvent($exception, self
::$_nullObject);
2048 \Civi
::dispatcher()->dispatch('hook_civicrm_unhandled_exception', $event);
2052 * This hook is called for declaring managed entities via API.
2054 * Note: This is a pre-boot hook. It will dispatch via the extension/module
2055 * subsystem but *not* the Symfony EventDispatcher.
2057 * @param array[] $entityTypes
2058 * List of entity types; each entity-type is an array with keys:
2059 * - name: string, a unique short name (e.g. "ReportInstance")
2060 * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance")
2061 * - table: string, a SQL table name (e.g. "civicrm_report_instance")
2062 * - fields_callback: array, list of callables which manipulates field list
2063 * - links_callback: array, list of callables which manipulates fk list
2066 * The return value is ignored
2068 public static function entityTypes(&$entityTypes) {
2069 return self
::singleton()->invoke(['entityTypes'], $entityTypes, self
::$_nullObject, self
::$_nullObject,
2070 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_entityTypes'
2075 * Build a description of available hooks.
2077 * @param \Civi\Core\CiviEventInspector $inspector
2079 public static function eventDefs($inspector) {
2080 $event = \Civi\Core\Event\GenericHookEvent
::create([
2081 'inspector' => $inspector,
2083 Civi
::dispatcher()->dispatch('hook_civicrm_eventDefs', $event);
2087 * This hook is called while preparing a profile form.
2089 * @param string $profileName
2092 public static function buildProfile($profileName) {
2093 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2094 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildProfile');
2098 * This hook is called while validating a profile form submission.
2100 * @param string $profileName
2103 public static function validateProfile($profileName) {
2104 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2105 self
::$_nullObject, self
::$_nullObject, 'civicrm_validateProfile');
2109 * This hook is called processing a valid profile form submission.
2111 * @param string $profileName
2114 public static function processProfile($profileName) {
2115 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2116 self
::$_nullObject, self
::$_nullObject, 'civicrm_processProfile');
2120 * This hook is called while preparing a read-only profile screen
2122 * @param string $profileName
2125 public static function viewProfile($profileName) {
2126 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2127 self
::$_nullObject, self
::$_nullObject, 'civicrm_viewProfile');
2131 * This hook is called while preparing a list of contacts (based on a profile)
2133 * @param string $profileName
2136 public static function searchProfile($profileName) {
2137 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2138 self
::$_nullObject, self
::$_nullObject, 'civicrm_searchProfile');
2142 * This hook is invoked when building a CiviCRM name badge.
2144 * @param string $labelName
2145 * String referencing name of badge format.
2146 * @param object $label
2147 * Reference to the label object.
2148 * @param array $format
2149 * Array of format data.
2150 * @param array $participant
2151 * Array of participant values.
2154 * the return value is ignored
2156 public static function alterBadge($labelName, &$label, &$format, &$participant) {
2157 return self
::singleton()
2158 ->invoke(['labelName', 'label', 'format', 'participant'], $labelName, $label, $format, $participant, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBadge');
2162 * This hook is called before encoding data in barcode.
2164 * @param array $data
2165 * Associated array of values available for encoding.
2166 * @param string $type
2167 * Type of barcode, classic barcode or QRcode.
2168 * @param string $context
2169 * Where this hooks is invoked.
2173 public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') {
2174 return self
::singleton()->invoke(['data', 'type', 'context'], $data, $type, $context, self
::$_nullObject,
2175 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBarcode');
2179 * Modify or replace the Mailer object used for outgoing mail.
2181 * @param object $mailer
2182 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
2183 * @param string $driver
2184 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
2185 * @param array $params
2186 * The default mailer config options
2189 * @see Mail::factory
2191 public static function alterMailer(&$mailer, $driver, $params) {
2192 return self
::singleton()
2193 ->invoke(['mailer', 'driver', 'params'], $mailer, $driver, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterMailer');
2197 * This hook is called while building the core search query,
2198 * so hook implementers can provide their own query objects which alters/extends core search.
2200 * @param array $queryObjects
2201 * @param string $type
2205 public static function queryObjects(&$queryObjects, $type = 'Contact') {
2206 return self
::singleton()
2207 ->invoke(['queryObjects', 'type'], $queryObjects, $type, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_queryObjects');
2211 * This hook is called while initializing the default dashlets for a contact dashboard.
2213 * @param array $availableDashlets
2214 * List of dashlets; each is formatted per api/v3/Dashboard
2215 * @param array $defaultDashlets
2216 * List of dashlets; each is formatted per api/v3/DashboardContact
2220 public static function dashboard_defaults($availableDashlets, &$defaultDashlets) {
2221 return self
::singleton()
2222 ->invoke(['availableDashlets', 'defaultDashlets'], $availableDashlets, $defaultDashlets, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_dashboard_defaults');
2226 * This hook is called before a case merge (or a case reassign)
2228 * @param int $mainContactId
2229 * @param int $mainCaseId
2230 * @param int $otherContactId
2231 * @param int $otherCaseId
2232 * @param bool $changeClient
2236 public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
2237 return self
::singleton()
2238 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_pre_case_merge');
2242 * This hook is called after a case merge (or a case reassign)
2244 * @param int $mainContactId
2245 * @param int $mainCaseId
2246 * @param int $otherContactId
2247 * @param int $otherCaseId
2248 * @param bool $changeClient
2252 public static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
2253 return self
::singleton()
2254 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_post_case_merge');
2259 * Add a hook for altering the display name
2261 * hook_civicrm_contact_get_displayname(&$display_name, $objContact)
2263 * @param string $displayName
2264 * @param int $contactId
2265 * @param object $dao
2266 * The contact object.
2270 public static function alterDisplayName(&$displayName, $contactId, $dao) {
2271 return self
::singleton()->invoke(['displayName', 'contactId', 'dao'],
2272 $displayName, $contactId, $dao, self
::$_nullObject, self
::$_nullObject,
2273 self
::$_nullObject, 'civicrm_contact_get_displayname'
2278 * Modify the CRM_Core_Resources settings data.
2280 * @param array $data
2281 * @see CRM_Core_Resources::addSetting
2283 public static function alterResourceSettings(&$data) {
2284 $event = \Civi\Core\Event\GenericHookEvent
::create([
2287 Civi
::dispatcher()->dispatch('hook_civicrm_alterResourceSettings', $event);
2291 * EXPERIMENTAL: This hook allows one to register additional Angular modules
2293 * @param array $angularModules
2294 * List of modules. Each module defines:
2295 * - ext: string, the CiviCRM extension which hosts the files.
2296 * - js: array, list of JS files or globs.
2297 * - css: array, list of CSS files or globs.
2298 * - partials: array, list of base-dirs containing HTML.
2299 * - partialsCallback: mixed, a callback function which generates a list of HTML
2300 * function(string $moduleName, array $moduleDefn) => array(string $file => string $html)
2301 * For future-proofing, use a serializable callback (e.g. string/array).
2302 * See also: Civi\Core\Resolver.
2303 * - requires: array, list of required Angular modules.
2304 * - basePages: array, uncondtionally load this module onto the given Angular pages. [v4.7.21+]
2305 * If omitted, default to "array('civicrm/a')" for backward compat.
2306 * For a utility that should only be loaded on-demand, use "array()".
2307 * For a utility that should be loaded in all pages use, "array('*')".
2310 * function mymod_civicrm_angularModules(&$angularModules) {
2311 * $angularModules['myAngularModule'] = array(
2312 * 'ext' => 'org.example.mymod',
2313 * 'js' => array('js/myAngularModule.js'),
2315 * $angularModules['myBigAngularModule'] = array(
2316 * 'ext' => 'org.example.mymod',
2317 * 'js' => array('js/part1.js', 'js/part2.js', 'ext://other.ext.name/file.js', 'assetBuilder://dynamicAsset.js'),
2318 * 'css' => array('css/myAngularModule.css', 'ext://other.ext.name/file.css', 'assetBuilder://dynamicAsset.css'),
2319 * 'partials' => array('partials/myBigAngularModule'),
2320 * 'requires' => array('otherModuleA', 'otherModuleB'),
2321 * 'basePages' => array('civicrm/a'),
2327 * the return value is ignored
2329 public static function angularModules(&$angularModules) {
2330 return self
::singleton()->invoke(['angularModules'], $angularModules,
2331 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2332 'civicrm_angularModules'
2337 * Alter the definition of some Angular HTML partials.
2339 * @param \Civi\Angular\Manager $angular
2342 * function example_civicrm_alterAngular($angular) {
2343 * $changeSet = \Civi\Angular\ChangeSet::create('mychanges')
2344 * ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(phpQueryObject $doc) {
2345 * $doc->find('[ng-form="crmMailingSubform"]')->attr('cat-stevens', 'ts(\'wild world\')');
2348 * $angular->add($changeSet);
2352 public static function alterAngular($angular) {
2353 $event = \Civi\Core\Event\GenericHookEvent
::create([
2354 'angular' => $angular,
2356 Civi
::dispatcher()->dispatch('hook_civicrm_alterAngular', $event);
2360 * This hook is called when building a link to a semi-static asset.
2362 * @param string $asset
2363 * The name of the asset.
2364 * Ex: 'angular.json'
2365 * @param array $params
2366 * List of optional arguments which influence the content.
2368 * the return value is ignored
2370 public static function getAssetUrl(&$asset, &$params) {
2371 return self
::singleton()->invoke(['asset', 'params'],
2372 $asset, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2373 'civicrm_getAssetUrl'
2378 * This hook is called whenever the system builds a new copy of
2379 * semi-static asset.
2381 * @param string $asset
2382 * The name of the asset.
2383 * Ex: 'angular.json'
2384 * @param array $params
2385 * List of optional arguments which influence the content.
2386 * Note: Params are immutable because they are part of the cache-key.
2387 * @param string $mimeType
2388 * Initially, NULL. Modify to specify the mime-type.
2389 * @param string $content
2390 * Initially, NULL. Modify to specify the rendered content.
2392 * the return value is ignored
2394 public static function buildAsset($asset, $params, &$mimeType, &$content) {
2395 return self
::singleton()->invoke(['asset', 'params', 'mimeType', 'content'],
2396 $asset, $params, $mimeType, $content, self
::$_nullObject, self
::$_nullObject,
2397 'civicrm_buildAsset'
2402 * This hook fires whenever a record in a case changes.
2404 * @param \Civi\CCase\Analyzer $analyzer
2405 * A bundle of data about the case (such as the case and activity records).
2407 public static function caseChange(\Civi\CCase\Analyzer
$analyzer) {
2408 $event = new \Civi\CCase\Event\
CaseChangeEvent($analyzer);
2409 \Civi
::dispatcher()->dispatch('hook_civicrm_caseChange', $event);
2413 * Modify the CiviCRM container - add new services, parameters, extensions, etc.
2416 * use Symfony\Component\Config\Resource\FileResource;
2417 * use Symfony\Component\DependencyInjection\Definition;
2419 * function mymodule_civicrm_container($container) {
2420 * $container->addResource(new FileResource(__FILE__));
2421 * $container->setDefinition('mysvc', new Definition('My\Class', array()));
2425 * Tip: The container configuration will be compiled/cached. The default cache
2426 * behavior is aggressive. When you first implement the hook, be sure to
2427 * flush the cache. Additionally, you should relax caching during development.
2428 * In `civicrm.settings.php`, set define('CIVICRM_CONTAINER_CACHE', 'auto').
2430 * Note: This is a preboot hook. It will dispatch via the extension/module
2431 * subsystem but *not* the Symfony EventDispatcher.
2433 * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
2434 * @see http://symfony.com/doc/current/components/dependency_injection/index.html
2436 public static function container(\Symfony\Component\DependencyInjection\ContainerBuilder
$container) {
2437 self
::singleton()->invoke(['container'], $container, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_container');
2441 * @param array $fileSearches CRM_Core_FileSearchInterface
2444 public static function fileSearches(&$fileSearches) {
2445 return self
::singleton()->invoke(['fileSearches'], $fileSearches,
2446 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2447 'civicrm_fileSearches'
2452 * Check system status.
2454 * @param CRM_Utils_Check_Message[] $messages
2455 * A list of messages regarding system status
2456 * @param array $statusNames
2457 * If specified, only these checks are being requested and others should be skipped
2458 * @param bool $includeDisabled
2459 * Run checks that have been explicitly disabled (default false)
2462 public static function check(&$messages, $statusNames = [], $includeDisabled = FALSE) {
2463 return self
::singleton()->invoke(['messages'],
2464 $messages, $statusNames, $includeDisabled,
2465 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2471 * This hook is called when a query string of the CSV Batch export is generated.
2473 * @param string $query
2477 public static function batchQuery(&$query) {
2478 return self
::singleton()->invoke(['query'], $query, self
::$_nullObject,
2479 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2480 'civicrm_batchQuery'
2485 * This hook is called to alter Deferred revenue item values just before they are
2486 * inserted in civicrm_financial_trxn table
2488 * @param array $deferredRevenues
2490 * @param array $contributionDetails
2492 * @param bool $update
2494 * @param string $context
2498 public static function alterDeferredRevenueItems(&$deferredRevenues, $contributionDetails, $update, $context) {
2499 return self
::singleton()->invoke(['deferredRevenues', 'contributionDetails', 'update', 'context'], $deferredRevenues, $contributionDetails, $update, $context,
2500 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterDeferredRevenueItems'
2505 * This hook is called when the entries of the CSV Batch export are mapped.
2507 * @param array $results
2508 * @param array $items
2512 public static function batchItems(&$results, &$items) {
2513 return self
::singleton()->invoke(['results', 'items'], $results, $items,
2514 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2515 'civicrm_batchItems'
2520 * This hook is called when core resources are being loaded
2522 * @see CRM_Core_Resources::coreResourceList
2524 * @param array $list
2525 * @param string $region
2527 public static function coreResourceList(&$list, $region) {
2528 self
::singleton()->invoke(['list', 'region'], $list, $region,
2529 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2530 'civicrm_coreResourceList'
2535 * Allows the list of filters on the EntityRef widget to be altered.
2537 * @see CRM_Core_Resources::entityRefFilters
2539 * @param array $filters
2540 * @param array $links
2542 public static function entityRefFilters(&$filters, &$links = NULL) {
2543 self
::singleton()->invoke(['filters', 'links'], $filters, $links, self
::$_nullObject,
2544 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2545 'civicrm_entityRefFilters'
2550 * This hook is called for bypass a few civicrm urls from IDS check.
2552 * @param array $skip list of civicrm urls
2556 public static function idsException(&$skip) {
2557 return self
::singleton()->invoke(['skip'], $skip, self
::$_nullObject,
2558 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2559 'civicrm_idsException'
2564 * This hook is called when a geocoder's format method is called.
2566 * @param string $geoProvider
2567 * @param array $values
2568 * @param SimpleXMLElement $xml
2572 public static function geocoderFormat($geoProvider, &$values, $xml) {
2573 return self
::singleton()->invoke(['geoProvider', 'values', 'xml'], $geoProvider, $values, $xml,
2574 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2575 'civicrm_geocoderFormat'
2580 * This hook is called before an inbound SMS is processed.
2582 * @param \CRM_SMS_Message $message
2583 * An SMS message received
2586 public static function inboundSMS(&$message) {
2587 return self
::singleton()->invoke(['message'], $message, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_inboundSMS');
2591 * This hook is called to modify api params of EntityRef form field
2593 * @param array $params
2594 * @param string $formName
2597 public static function alterEntityRefParams(&$params, $formName) {
2598 return self
::singleton()->invoke(['params', 'formName'], $params, $formName,
2599 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2600 'civicrm_alterEntityRefParams'
2605 * This hook is called before a scheduled job is executed
2607 * @param CRM_Core_DAO_Job $job
2608 * The job to be executed
2609 * @param array $params
2610 * The arguments to be given to the job
2612 public static function preJob($job, $params) {
2613 return self
::singleton()->invoke(['job', 'params'], $job, $params,
2614 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2620 * This hook is called after a scheduled job is executed
2622 * @param CRM_Core_DAO_Job $job
2623 * The job that was executed
2624 * @param array $params
2625 * The arguments given to the job
2626 * @param array $result
2627 * The result of the API call, or the thrown exception if any
2629 public static function postJob($job, $params, $result) {
2630 return self
::singleton()->invoke(['job', 'params', 'result'], $job, $params, $result,
2631 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2637 * This hook is called before and after constructing mail recipients.
2638 * Allows user to alter filter and/or search query to fetch mail recipients
2640 * @param CRM_Mailing_DAO_Mailing $mailingObject
2641 * @param array $criteria
2642 * A list of SQL criteria; you can add/remove/replace/modify criteria.
2643 * Array(string $name => CRM_Utils_SQL_Select $criterion).
2644 * Ex: array('do_not_email' => CRM_Utils_SQL_Select::fragment()->where("$contact.do_not_email = 0")).
2645 * @param string $context
2649 public static function alterMailingRecipients(&$mailingObject, &$criteria, $context) {
2650 return self
::singleton()->invoke(['mailingObject', 'params', 'context'],
2651 $mailingObject, $criteria, $context,
2652 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2653 'civicrm_alterMailingRecipients'
2658 * ALlow Extensions to custom process IPN hook data such as sending Google Analyitcs information based on the IPN
2659 * @param array $IPNData - Array of IPN Data
2662 public static function postIPNProcess(&$IPNData) {
2663 return self
::singleton()->invoke(['IPNData'],
2664 $IPNData, self
::$_nullObject, self
::$_nullObject,
2665 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2666 'civicrm_postIPNProcess'
2671 * Allow extensions to modify the array of acceptable fields to be included on profiles
2672 * @param array $fields
2673 * format is [Entity => array of DAO fields]
2676 public static function alterUFFields(&$fields) {
2677 return self
::singleton()->invoke(['fields'],
2678 $fields, self
::$_nullObject, self
::$_nullObject,
2679 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2680 'civicrm_alterUFFields'
2685 * This hook is called to alter Custom field value before its displayed.
2687 * @param string $displayValue
2688 * @param mixed $value
2689 * @param int $entityId
2690 * @param array $fieldInfo
2694 public static function alterCustomFieldDisplayValue(&$displayValue, $value, $entityId, $fieldInfo) {
2695 return self
::singleton()->invoke(
2696 ['displayValue', 'value', 'entityId', 'fieldInfo'],
2697 $displayValue, $value, $entityId, $fieldInfo, self
::$_nullObject,
2698 self
::$_nullObject, 'civicrm_alterCustomFieldDisplayValue'