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|int $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 // Per https://github.com/civicrm/civicrm-core/pull/13551 we have had ongoing significant problems where hooks from modules are
156 // invoked during upgrade but not those from extensions. The issues are both that an incorrect module list & settings are cached and that
157 // some hooks REALLY need to run during upgrade - the loss of triggers during upgrade causes significant loss of data
158 // whereas loss of logTable hooks means that log tables are created for tables specifically excluded - e.g due to large
159 // quantities of low-importance data or the table not having an id field, which could cause a fatal error.
160 // Instead of not calling any hooks we only call those we know to be frequently important - if a particular extension wanted
161 // to avoid this they could do an early return on CRM_Core_Config::singleton()->isUpgradeMode
162 // Futther discussion is happening at https://lab.civicrm.org/dev/core/issues/1460
163 $upgradeFriendlyHooks = ['civicrm_alterSettingsFolders', 'civicrm_alterSettingsMetaData', 'civicrm_triggerInfo', 'civicrm_alterLogTables', 'civicrm_container', 'civicrm_permission', 'civicrm_managed', 'civicrm_config'];
164 if (CRM_Core_Config
::singleton()->isUpgradeMode() && !in_array($fnSuffix, $upgradeFriendlyHooks)) {
167 if (is_array($names) && !defined('CIVICRM_FORCE_LEGACY_HOOK') && \Civi\Core\Container
::isContainerBooted()) {
168 $event = \Civi\Core\Event\GenericHookEvent
::createOrdered(
170 array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6)
172 \Civi
::dispatcher()->dispatch('hook_' . $fnSuffix, $event);
173 return $event->getReturnValues();
176 // We need to ensure tht we will still run known bootstrap related hooks even if the container is not booted.
177 $prebootContainerHooks = array_merge($upgradeFriendlyHooks, ['civicrm_entityTypes', 'civicrm_config']);
178 if (!\Civi\Core\Container
::isContainerBooted() && !in_array($fnSuffix, $prebootContainerHooks)) {
181 $count = is_array($names) ?
count($names) : $names;
182 return $this->invokeViaUF($count, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $fnSuffix);
187 * @param array $numParams
199 public function commonInvoke(
201 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
205 $this->commonBuildModuleList($fnPrefix);
207 return $this->runHooks($this->commonCiviModules
, $fnSuffix,
208 $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6
213 * Build the list of modules to be processed for hooks.
215 * @param string $fnPrefix
217 public function commonBuildModuleList($fnPrefix) {
218 if (!$this->commonIncluded
) {
219 // include external file
220 $this->commonIncluded
= TRUE;
222 $config = CRM_Core_Config
::singleton();
223 if (!empty($config->customPHPPathDir
)) {
224 $civicrmHooksFile = CRM_Utils_File
::addTrailingSlash($config->customPHPPathDir
) . 'civicrmHooks.php';
225 if (file_exists($civicrmHooksFile)) {
226 @include_once
$civicrmHooksFile;
230 if (!empty($fnPrefix)) {
231 $this->commonCiviModules
[$fnPrefix] = $fnPrefix;
234 $this->requireCiviModules($this->commonCiviModules
);
241 * @param array $civiModules
242 * @param string $fnSuffix
243 * @param int $numParams
252 * @throws \CRM_Core_Exception
254 public function runHooks(
255 $civiModules, $fnSuffix, $numParams,
256 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6
258 // $civiModules is *not* passed by reference because runHooks
259 // must be reentrant. PHP is finicky about running
260 // multiple loops over the same variable. The circumstances
261 // to reproduce the issue are pretty intricate.
264 $fnNames = $this->cache
->get($fnSuffix);
265 if (!is_array($fnNames)) {
267 if ($civiModules !== NULL) {
268 foreach ($civiModules as $module) {
269 $fnName = "{$module}_{$fnSuffix}";
270 if (function_exists($fnName)) {
271 $fnNames[] = $fnName;
274 $this->cache
->set($fnSuffix, $fnNames);
278 foreach ($fnNames as $fnName) {
280 switch ($numParams) {
282 $fResult = $fnName();
286 $fResult = $fnName($arg1);
290 $fResult = $fnName($arg1, $arg2);
294 $fResult = $fnName($arg1, $arg2, $arg3);
298 $fResult = $fnName($arg1, $arg2, $arg3, $arg4);
302 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5);
306 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
310 throw new CRM_Core_Exception(ts('Invalid hook invocation'));
313 if (!empty($fResult) &&
316 $result = array_merge($result, $fResult);
320 return empty($result) ?
TRUE : $result;
326 public function requireCiviModules(&$moduleList) {
327 $civiModules = CRM_Core_PseudoConstant
::getModuleExtensions();
328 foreach ($civiModules as $civiModule) {
329 if (!file_exists($civiModule['filePath'])) {
330 CRM_Core_Session
::setStatus(
331 ts('Error loading module file (%1). Please restore the file or disable the module.',
332 [1 => $civiModule['filePath']]),
333 ts('Warning'), 'error');
336 include_once $civiModule['filePath'];
337 $moduleList[$civiModule['prefix']] = $civiModule['prefix'];
342 * This hook is called before a db write on some core objects.
343 * This hook does not allow the abort of the operation
346 * The type of operation being performed.
347 * @param string $objectName
348 * The name of the object.
350 * The object id if available.
351 * @param array $params
352 * The parameters used for object creation / editing.
355 * the return value is ignored
357 public static function pre($op, $objectName, $id, &$params) {
358 // Dev/core#1449 DO not dispatch hook_civicrm_pre if we are in an upgrade as this cases the upgrade to fail
359 // Futher discussion is happening at https://lab.civicrm.org/dev/core/issues/1460
360 if (CRM_Core_Config
::singleton()->isUpgradeMode()) {
363 $event = new \Civi\Core\Event\
PreEvent($op, $objectName, $id, $params);
364 \Civi
::dispatcher()->dispatch('hook_civicrm_pre', $event);
365 return $event->getReturnValues();
369 * This hook is called after a db write on some core objects.
372 * The type of operation being performed.
373 * @param string $objectName
374 * The name of the object.
375 * @param int $objectId
376 * The unique identifier for the object.
377 * @param object $objectRef
378 * The reference to the object if available.
381 * based on op. pre-hooks return a boolean or
382 * an error message which aborts the operation
384 public static function post($op, $objectName, $objectId, &$objectRef = NULL) {
385 // Dev/core#1449 DO not dispatch hook_civicrm_post if we are in an upgrade as this cases the upgrade to fail
386 // Futher discussion is happening at https://lab.civicrm.org/dev/core/issues/1460
387 if (CRM_Core_Config
::singleton()->isUpgradeMode()) {
390 $event = new \Civi\Core\Event\
PostEvent($op, $objectName, $objectId, $objectRef);
391 \Civi
::dispatcher()->dispatch('hook_civicrm_post', $event);
392 return $event->getReturnValues();
396 * This hook is equivalent to post(), except that it is guaranteed to run
397 * outside of any SQL transaction. The objectRef is not modifiable.
399 * This hook is defined for two cases:
401 * 1. If the original action runs within a transaction, then the hook fires
402 * after the transaction commits.
403 * 2. If the original action runs outside a transaction, then the data was
404 * committed immediately, and we can run the hook immediately.
407 * The type of operation being performed.
408 * @param string $objectName
409 * The name of the object.
410 * @param int $objectId
411 * The unique identifier for the object.
412 * @param object $objectRef
413 * The reference to the object if available.
416 * based on op. pre-hooks return a boolean or
417 * an error message which aborts the operation
419 public static function postCommit($op, $objectName, $objectId, $objectRef = NULL) {
420 $event = new \Civi\Core\Event\
PostEvent($op, $objectName, $objectId, $objectRef);
421 \Civi
::dispatcher()->dispatch('hook_civicrm_postCommit', $event);
422 return $event->getReturnValues();
426 * This hook retrieves links from other modules and injects it into.
427 * the view contact tabs
430 * The type of operation being performed.
431 * @param string $objectName
432 * The name of the object.
433 * @param int $objectId
434 * The unique identifier for the object.
435 * @param array $links
436 * (optional) the links array (introduced in v3.2).
438 * (optional) the bitmask to show/hide links.
439 * @param array $values
440 * (optional) the values to fill the links.
443 * the return value is ignored
445 public static function links($op, $objectName, &$objectId, &$links, &$mask = NULL, &$values = []) {
446 return self
::singleton()->invoke(['op', 'objectName', 'objectId', 'links', 'mask', 'values'], $op, $objectName, $objectId, $links, $mask, $values, 'civicrm_links');
450 * This hook is invoked during the CiviCRM form preProcess phase.
452 * @param string $formName
453 * The name of the form.
454 * @param CRM_Core_Form $form
455 * Reference to the form object.
458 * the return value is ignored
460 public static function preProcess($formName, &$form) {
461 return self
::singleton()
462 ->invoke(['formName', 'form'], $formName, $form, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_preProcess');
466 * This hook is invoked when building a CiviCRM form. This hook should also
467 * be used to set the default values of a form element
469 * @param string $formName
470 * The name of the form.
471 * @param CRM_Core_Form $form
472 * Reference to the form object.
475 * the return value is ignored
477 public static function buildForm($formName, &$form) {
478 return self
::singleton()->invoke(['formName', 'form'], $formName, $form,
479 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
485 * This hook is invoked when a CiviCRM form is submitted. If the module has injected
486 * any form elements, this hook should save the values in the database
488 * @param string $formName
489 * The name of the form.
490 * @param CRM_Core_Form $form
491 * Reference to the form object.
494 * the return value is ignored
496 public static function postProcess($formName, &$form) {
497 return self
::singleton()->invoke(['formName', 'form'], $formName, $form,
498 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
499 'civicrm_postProcess'
504 * This hook is invoked during all CiviCRM form validation. An array of errors
505 * detected is returned. Else we assume validation succeeded.
507 * @param string $formName
508 * The name of the form.
509 * @param array &$fields the POST parameters as filtered by QF
510 * @param array &$files the FILES parameters as sent in by POST
511 * @param array &$form the form object
512 * @param array &$errors the array of errors.
515 * formRule hooks return a boolean or
516 * an array of error messages which display a QF Error
518 public static function validateForm($formName, &$fields, &$files, &$form, &$errors) {
519 return self
::singleton()
520 ->invoke(['formName', 'fields', 'files', 'form', 'errors'],
521 $formName, $fields, $files, $form, $errors, self
::$_nullObject, 'civicrm_validateForm');
525 * This hook is called after a db write on a custom table.
528 * The type of operation being performed.
529 * @param string $groupID
530 * The custom group ID.
531 * @param object $entityID
532 * The entityID of the row in the custom table.
533 * @param array $params
534 * The parameters that were sent into the calling function.
537 * the return value is ignored
539 public static function custom($op, $groupID, $entityID, &$params) {
540 return self
::singleton()
541 ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_custom');
545 * This hook is called when composing the ACL where clause to restrict
546 * visibility of contacts to the logged in user
549 * The type of permission needed.
550 * @param array $tables
551 * (reference ) add the tables that are needed for the select clause.
552 * @param array $whereTables
553 * (reference ) add the tables that are needed for the where clause.
554 * @param int $contactID
555 * The contactID for whom the check is made.
556 * @param string $where
557 * The currrent where clause.
560 * the return value is ignored
562 public static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) {
563 return self
::singleton()
564 ->invoke(['type', 'tables', 'whereTables', 'contactID', 'where'], $type, $tables, $whereTables, $contactID, $where, self
::$_nullObject, 'civicrm_aclWhereClause');
568 * This hook is called when composing the ACL where clause to restrict
569 * visibility of contacts to the logged in user
572 * The type of permission needed.
573 * @param int $contactID
574 * The contactID for whom the check is made.
575 * @param string $tableName
576 * The tableName which is being permissioned.
577 * @param array $allGroups
578 * The set of all the objects for the above table.
579 * @param array $currentGroups
580 * The set of objects that are currently permissioned for this contact.
583 * the return value is ignored
585 public static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) {
586 return self
::singleton()
587 ->invoke(['type', 'contactID', 'tableName', 'allGroups', 'currentGroups'], $type, $contactID, $tableName, $allGroups, $currentGroups, self
::$_nullObject, 'civicrm_aclGroup');
591 * @param string|CRM_Core_DAO $entity
592 * @param array $clauses
595 public static function selectWhereClause($entity, &$clauses) {
596 $entityName = is_object($entity) ?
_civicrm_api_get_entity_name_from_dao($entity) : $entity;
597 return self
::singleton()->invoke(['entity', 'clauses'], $entityName, $clauses,
598 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
599 'civicrm_selectWhereClause'
604 * This hook is called when building the menu table.
606 * @param array $files
607 * The current set of files to process.
610 * the return value is ignored
612 public static function xmlMenu(&$files) {
613 return self
::singleton()->invoke(['files'], $files,
614 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
620 * (Experimental) This hook is called when build the menu table.
622 * @param array $items
623 * List of records to include in menu table.
625 * the return value is ignored
627 public static function alterMenu(&$items) {
628 return self
::singleton()->invoke(['items'], $items,
629 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
635 * A theme is a set of CSS files which are loaded on CiviCRM pages. To register a new
636 * theme, add it to the $themes array. Use these properties:
638 * - ext: string (required)
639 * The full name of the extension which defines the theme.
640 * Ex: "org.civicrm.themes.greenwich".
641 * - title: string (required)
643 * - help: string (optional)
644 * Description of the theme's appearance.
645 * - url_callback: mixed (optional)
646 * A function ($themes, $themeKey, $cssExt, $cssFile) which returns the URL(s) for a CSS resource.
647 * Returns either an array of URLs or PASSTHRU.
648 * Ex: \Civi\Core\Themes\Resolvers::simple (default)
649 * Ex: \Civi\Core\Themes\Resolvers::none
650 * - prefix: string (optional)
651 * A prefix within the extension folder to prepend to the file name.
652 * - search_order: array (optional)
653 * A list of themes to search.
654 * Generally, the last theme should be "*fallback*" (Civi\Core\Themes::FALLBACK).
655 * - excludes: array (optional)
656 * A list of files (eg "civicrm:css/bootstrap.css" or "$ext:$file") which should never
657 * be returned (they are excluded from display).
659 * @param array $themes
660 * List of themes, keyed by name.
662 * the return value is ignored
664 public static function themes(&$themes) {
665 return self
::singleton()->invoke(1, $themes,
666 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
672 * The activeTheme hook determines which theme is active.
674 * @param string $theme
675 * The identifier for the theme. Alterable.
677 * @param array $context
678 * Information about the current page-request. Includes some mix of:
679 * - page: the relative path of the current Civi page (Ex: 'civicrm/dashboard').
680 * - themes: an instance of the Civi\Core\Themes service.
682 * the return value is ignored
684 public static function activeTheme(&$theme, $context) {
685 return self
::singleton()->invoke(array('theme', 'context'), $theme, $context,
686 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
687 'civicrm_activeTheme'
692 * This hook is called for declaring managed entities via API.
694 * @param array $entities
695 * List of pending entities. Each entity is an array with keys:
696 * + '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")
697 * + 'name': string, a symbolic name which can be used to track this entity (Note: Each module creates its own namespace)
698 * + 'entity': string, an entity-type supported by the CiviCRM API (Note: this currently must be an entity which supports the 'is_active' property)
699 * + 'params': array, the entity data as supported by the CiviCRM API
700 * + 'update' (v4.5+): string, a policy which describes when to update records
701 * - 'always' (default): always update the managed-entity record; changes in $entities will override any local changes (eg by the site-admin)
702 * - 'never': never update the managed-entity record; changes made locally (eg by the site-admin) will override changes in $entities
703 * + '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)
704 * - 'always' (default): always delete orphaned records
705 * - 'never': never delete orphaned records
706 * - '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.)
709 * the return value is ignored
711 public static function managed(&$entities) {
712 return self
::singleton()->invoke(['entities'], $entities,
713 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
719 * This hook is called when rendering the dashboard (q=civicrm/dashboard)
721 * @param int $contactID
722 * The contactID for whom the dashboard is being rendered.
723 * @param int $contentPlacement
724 * (output parameter) where should the hook content be displayed.
725 * relative to the activity list
728 * the html snippet to include in the dashboard
730 public static function dashboard($contactID, &$contentPlacement = self
::DASHBOARD_BELOW
) {
731 $retval = self
::singleton()->invoke(['contactID', 'contentPlacement'], $contactID, $contentPlacement,
732 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
737 * Note we need this seemingly unnecessary code because in the event that the implementation
738 * of the hook declares the second parameter but doesn't set it, then it comes back unset even
739 * though we have a default value in this function's declaration above.
741 if (!isset($contentPlacement)) {
742 $contentPlacement = self
::DASHBOARD_BELOW
;
749 * This hook is called before storing recently viewed items.
751 * @param array $recentArray
752 * An array of recently viewed or processed items, for in place modification.
756 public static function recent(&$recentArray) {
757 return self
::singleton()->invoke(['recentArray'], $recentArray,
758 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
764 * Determine how many other records refer to a given record.
766 * @param CRM_Core_DAO $dao
767 * The item for which we want a reference count.
768 * @param array $refCounts
769 * Each item in the array is an Array with keys:
770 * - name: string, eg "sql:civicrm_email:contact_id"
771 * - type: string, eg "sql"
772 * - count: int, eg "5" if there are 5 email addresses that refer to $dao
775 * Return is not really intended to be used.
777 public static function referenceCounts($dao, &$refCounts) {
778 return self
::singleton()->invoke(['dao', 'refCounts'], $dao, $refCounts,
779 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
780 'civicrm_referenceCounts'
785 * This hook is called when building the amount structure for a Contribution or Event Page.
787 * @param int $pageType
788 * Is this a contribution or event page.
789 * @param CRM_Core_Form $form
790 * Reference to the form object.
791 * @param array $amount
792 * The amount structure to be displayed.
796 public static function buildAmount($pageType, &$form, &$amount) {
797 return self
::singleton()->invoke(['pageType', 'form', 'amount'], $pageType, $form, $amount, self
::$_nullObject,
798 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildAmount');
802 * This hook is called when building the state list for a particular country.
804 * @param array $countryID
805 * The country id whose states are being selected.
810 public static function buildStateProvinceForCountry($countryID, &$states) {
811 return self
::singleton()->invoke(['countryID', 'states'], $countryID, $states,
812 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
813 'civicrm_buildStateProvinceForCountry'
818 * This hook is called when rendering the tabs for a contact (q=civicrm/contact/view)c
821 * The array of tabs that will be displayed.
822 * @param int $contactID
823 * The contactID for whom the dashboard is being rendered.
826 * @deprecated Use tabset() instead.
828 public static function tabs(&$tabs, $contactID) {
829 return self
::singleton()->invoke(['tabs', 'contactID'], $tabs, $contactID,
830 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabs'
835 * This hook is called when rendering the tabs used for events and potentially
836 * contribution pages, etc.
838 * @param string $tabsetName
839 * Name of the screen or visual element.
841 * Tabs that will be displayed.
842 * @param array $context
843 * Extra data about the screen or context in which the tab is used.
847 public static function tabset($tabsetName, &$tabs, $context) {
848 return self
::singleton()->invoke(['tabsetName', 'tabs', 'context'], $tabsetName, $tabs,
849 $context, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabset'
854 * This hook is called when sending an email / printing labels
856 * @param array $tokens
857 * The list of tokens that can be used for the contact.
861 public static function tokens(&$tokens) {
862 return self
::singleton()->invoke(['tokens'], $tokens,
863 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tokens'
868 * This hook allows modification of the admin panels
870 * @param array $panels
871 * Associated array of admin panels
875 public static function alterAdminPanel(&$panels) {
876 return self
::singleton()->invoke(array('panels'), $panels,
877 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
878 'civicrm_alterAdminPanel'
883 * This hook is called when sending an email / printing labels to get the values for all the
884 * tokens returned by the 'tokens' hook
886 * @param array $details
887 * The array to store the token values indexed by contactIDs.
888 * @param array $contactIDs
889 * An array of contactIDs.
891 * The jobID if this is associated with a CiviMail mailing.
892 * @param array $tokens
893 * The list of tokens associated with the content.
894 * @param string $className
895 * The top level className from where the hook is invoked.
899 public static function tokenValues(
906 return self
::singleton()
907 ->invoke(['details', 'contactIDs', 'jobID', 'tokens', 'className'], $details, $contactIDs, $jobID, $tokens, $className, self
::$_nullObject, 'civicrm_tokenValues');
911 * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables
914 * @param object $page
915 * The page that will be rendered.
919 public static function pageRun(&$page) {
920 return self
::singleton()->invoke(['page'], $page,
921 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
927 * This hook is called after a copy of an object has been made. The current objects are
928 * Event, Contribution Page and UFGroup
930 * @param string $objectName
931 * Name of the object.
932 * @param object $object
933 * Reference to the copy.
937 public static function copy($objectName, &$object) {
938 return self
::singleton()->invoke(['objectName', 'object'], $objectName, $object,
939 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
945 * This hook is called when a contact unsubscribes from a mailing. It allows modules
946 * to override what the contacts are removed from.
950 * @param int $mailingId
951 * The id of the mailing to unsub from
952 * @param int $contactId
953 * The id of the contact who is unsubscribing
954 * @param array|int $groups
955 * Groups the contact will be removed from.
956 * @param array|int $baseGroups
957 * Base groups (used in smart mailings) the contact will be removed from.
962 public static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) {
963 return self
::singleton()
964 ->invoke(['op', 'mailingId', 'contactId', 'groups', 'baseGroups'], $op, $mailingId, $contactId, $groups, $baseGroups, self
::$_nullObject, 'civicrm_unsubscribeGroups');
968 * This hook is called when CiviCRM needs to edit/display a custom field with options
970 * @deprecated in favor of hook_civicrm_fieldOptions
972 * @param int $customFieldID
973 * The custom field ID.
974 * @param array $options
975 * The current set of options for that custom field.
976 * You can add/remove existing options.
977 * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important
978 * to be careful to not overwrite the array.
979 * Only add/edit/remove the specific field options you intend to affect.
980 * @param bool $detailedFormat
981 * If true, the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format
982 * @param array $selectAttributes
983 * Contain select attribute(s) if any.
987 public static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE, $selectAttributes = []) {
988 // Weird: $selectAttributes is inputted but not outputted.
989 return self
::singleton()->invoke(['customFieldID', 'options', 'detailedFormat'], $customFieldID, $options, $detailedFormat,
990 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
991 'civicrm_customFieldOptions'
996 * Hook for modifying field options
998 * @param string $entity
999 * @param string $field
1000 * @param array $options
1001 * @param array $params
1005 public static function fieldOptions($entity, $field, &$options, $params) {
1006 return self
::singleton()->invoke(['entity', 'field', 'options', 'params'], $entity, $field, $options, $params,
1007 self
::$_nullObject, self
::$_nullObject,
1008 'civicrm_fieldOptions'
1014 * This hook is called to display the list of actions allowed after doing a search.
1015 * This allows the module developer to inject additional actions or to remove existing actions.
1017 * @param string $objectType
1018 * The object type for this search.
1019 * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported.
1020 * @param array $tasks
1021 * The current set of tasks for that custom field.
1022 * You can add/remove existing tasks.
1023 * Each task needs to have a title (eg 'title' => ts( 'Group - add contacts')) and a class
1024 * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
1025 * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
1026 * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be
1027 * found in CRM/$objectType/Task.php.
1031 public static function searchTasks($objectType, &$tasks) {
1032 return self
::singleton()->invoke(['objectType', 'tasks'], $objectType, $tasks,
1033 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1034 'civicrm_searchTasks'
1039 * @param mixed $form
1040 * @param array $params
1044 public static function eventDiscount(&$form, &$params) {
1045 return self
::singleton()->invoke(['form', 'params'], $form, $params,
1046 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1047 'civicrm_eventDiscount'
1052 * This hook is called when composing a mailing. You can include / exclude other groups as needed.
1054 * @param mixed $form
1055 * The form object for which groups / mailings being displayed
1056 * @param array $groups
1057 * The list of groups being included / excluded
1058 * @param array $mailings
1059 * The list of mailings being included / excluded
1063 public static function mailingGroups(&$form, &$groups, &$mailings) {
1064 return self
::singleton()->invoke(['form', 'groups', 'mailings'], $form, $groups, $mailings,
1065 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1066 'civicrm_mailingGroups'
1071 * (Experimental) Modify the list of template-types used for CiviMail composition.
1073 * @param array $types
1074 * Sequentially indexed list of template types. Each type specifies:
1076 * - editorUrl: string, Angular template URL
1077 * - weight: int, priority when picking a default value for new mailings
1080 public static function mailingTemplateTypes(&$types) {
1081 return self
::singleton()->invoke(['types'], $types, self
::$_nullObject, self
::$_nullObject,
1082 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1083 'civicrm_mailingTemplateTypes'
1088 * This hook is called when composing the array of membershipTypes and their cost during a membership registration
1090 * Note the hook is called on initial page load and also reloaded after submit (PRG pattern).
1091 * You can use it to alter the membership types when first loaded, or after submission
1092 * (for example if you want to gather data in the form and use it to alter the fees).
1094 * @param mixed $form
1095 * The form object that is presenting the page
1096 * @param array $membershipTypes
1097 * The array of membership types and their amount
1101 public static function membershipTypeValues(&$form, &$membershipTypes) {
1102 return self
::singleton()->invoke(['form', 'membershipTypes'], $form, $membershipTypes,
1103 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1104 'civicrm_membershipTypeValues'
1109 * This hook is called when rendering the contact summary.
1111 * @param int $contactID
1112 * The contactID for whom the summary is being rendered
1113 * @param mixed $content
1114 * @param int $contentPlacement
1115 * Specifies where the hook content should be displayed relative to the
1119 * The html snippet to include in the contact summary
1121 public static function summary($contactID, &$content, &$contentPlacement = self
::SUMMARY_BELOW
) {
1122 return self
::singleton()->invoke(['contactID', 'content', 'contentPlacement'], $contactID, $content, $contentPlacement,
1123 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1129 * Use this hook to populate the list of contacts returned by Contact Reference custom fields.
1130 * By default, Contact Reference fields will search on and return all CiviCRM contacts.
1131 * If you want to limit the contacts returned to a specific group, or some other criteria
1132 * - you can override that behavior by providing a SQL query that returns some subset of your contacts.
1133 * The hook is called when the query is executed to get the list of contacts to display.
1135 * @param mixed $query
1136 * - the query that will be executed (input and output parameter);.
1137 * It's important to realize that the ACL clause is built prior to this hook being fired,
1138 * so your query will ignore any ACL rules that may be defined.
1139 * Your query must return two columns:
1140 * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data')
1142 * @param string $queryText
1143 * The name string to execute the query against (this is the value being typed in by the user).
1144 * @param string $context
1145 * The context in which this ajax call is being made (for example: 'customfield', 'caseview').
1147 * The id of the object for which the call is being made.
1148 * For custom fields, it will be the custom field id
1152 public static function contactListQuery(&$query, $queryText, $context, $id) {
1153 return self
::singleton()->invoke(['query', 'queryText', 'context', 'id'], $query, $queryText, $context, $id,
1154 self
::$_nullObject, self
::$_nullObject,
1155 'civicrm_contactListQuery'
1160 * Hook definition for altering payment parameters before talking to a payment processor back end.
1162 * Definition will look like this:
1164 * function hook_civicrm_alterPaymentProcessorParams(
1170 * @param CRM_Core_Payment $paymentObj
1171 * Instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy')
1172 * See discussion in CRM-16224 as to whether $paymentObj should be passed by reference.
1173 * @param array &$rawParams
1174 * array of params as passed to to the processor
1175 * @param array &$cookedParams
1176 * params after the processor code has translated them into its own key/value pairs
1179 * This return is not really intended to be used.
1181 public static function alterPaymentProcessorParams(
1186 return self
::singleton()->invoke(['paymentObj', 'rawParams', 'cookedParams'], $paymentObj, $rawParams, $cookedParams,
1187 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1188 'civicrm_alterPaymentProcessorParams'
1193 * This hook is called when an email is about to be sent by CiviCRM.
1195 * @param array $params
1196 * Array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html,
1197 * returnPath, replyTo, headers, attachments (array)
1198 * @param string $context
1199 * The context in which the hook is being invoked, eg 'civimail'.
1203 public static function alterMailParams(&$params, $context = NULL) {
1204 return self
::singleton()->invoke(['params', 'context'], $params, $context,
1205 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1206 'civicrm_alterMailParams'
1211 * This hook is called when membership status is being calculated.
1213 * @param array $membershipStatus
1214 * Membership status details as determined - alter if required.
1215 * @param array $arguments
1216 * Arguments passed in to calculate date.
1221 * - 'exclude_is_admin'
1222 * - 'membership_type_id'
1223 * @param array $membership
1224 * Membership details from the calling function.
1228 public static function alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) {
1229 return self
::singleton()->invoke(['membershipStatus', 'arguments', 'membership'], $membershipStatus, $arguments,
1230 $membership, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1231 'civicrm_alterCalculatedMembershipStatus'
1236 * This hook is called after getting the content of the mail and before tokenizing it.
1238 * @param array $content
1239 * Array fields include: html, text, subject
1243 public static function alterMailContent(&$content) {
1244 return self
::singleton()->invoke(['content'], $content,
1245 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1246 'civicrm_alterMailContent'
1251 * This hook is called when rendering the Manage Case screen.
1253 * @param int $caseID
1257 * Array of data to be displayed, where the key is a unique id to be used for styling (div id's)
1258 * and the value is an array with keys 'label' and 'value' specifying label/value pairs
1260 public static function caseSummary($caseID) {
1261 return self
::singleton()->invoke(['caseID'], $caseID,
1262 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1263 'civicrm_caseSummary'
1268 * This hook is called when locating CiviCase types.
1270 * @param array $caseTypes
1274 public static function caseTypes(&$caseTypes) {
1275 return self
::singleton()
1276 ->invoke(['caseTypes'], $caseTypes, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_caseTypes');
1280 * This hook is called soon after the CRM_Core_Config object has ben initialized.
1281 * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically.
1283 * @param CRM_Core_Config|array $config
1288 public static function config(&$config) {
1289 return self
::singleton()->invoke(['config'], $config,
1290 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1296 * This hooks allows to change option values.
1298 * @deprecated in favor of hook_civicrm_fieldOptions
1300 * @param array $options
1301 * Associated array of option values / id
1302 * @param string $groupName
1307 public static function optionValues(&$options, $groupName) {
1308 return self
::singleton()->invoke(['options', 'groupName'], $options, $groupName,
1309 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1310 'civicrm_optionValues'
1315 * This hook allows modification of the navigation menu.
1317 * @param array $params
1318 * Associated array of navigation menu entry to Modify/Add
1322 public static function navigationMenu(&$params) {
1323 return self
::singleton()->invoke(['params'], $params,
1324 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1325 'civicrm_navigationMenu'
1330 * This hook allows modification of the data used to perform merging of duplicates.
1332 * @param string $type
1333 * The type of data being passed (cidRefs|eidRefs|relTables|sqls).
1334 * @param array $data
1335 * The data, as described in $type.
1336 * @param int $mainId
1337 * Contact_id of the contact that survives the merge.
1338 * @param int $otherId
1339 * Contact_id of the contact that will be absorbed and deleted.
1340 * @param array $tables
1341 * When $type is "sqls", an array of tables as it may have been handed to the calling function.
1345 public static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) {
1346 return self
::singleton()->invoke(['type', 'data', 'mainId', 'otherId', 'tables'], $type, $data, $mainId, $otherId, $tables, self
::$_nullObject, 'civicrm_merge');
1350 * This hook allows modification of the data calculated for merging locations.
1352 * @param array $blocksDAO
1353 * Array of location DAO to be saved. These are arrays in 2 keys 'update' & 'delete'.
1354 * @param int $mainId
1355 * Contact_id of the contact that survives the merge.
1356 * @param int $otherId
1357 * Contact_id of the contact that will be absorbed and deleted.
1358 * @param array $migrationInfo
1359 * Calculated migration info, informational only.
1363 public static function alterLocationMergeData(&$blocksDAO, $mainId, $otherId, $migrationInfo) {
1364 return self
::singleton()->invoke(['blocksDAO', 'mainId', 'otherId', 'migrationInfo'], $blocksDAO, $mainId, $otherId, $migrationInfo, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterLocationMergeData');
1368 * This hook provides a way to override the default privacy behavior for notes.
1370 * @param array &$noteValues
1371 * Associative array of values for this note
1375 public static function notePrivacy(&$noteValues) {
1376 return self
::singleton()->invoke(['noteValues'], $noteValues,
1377 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1378 'civicrm_notePrivacy'
1383 * This hook is called before record is exported as CSV.
1385 * @param string $exportTempTable
1386 * Name of the temporary export table used during export.
1387 * @param array $headerRows
1388 * Header rows for output.
1389 * @param array $sqlColumns
1391 * @param int $exportMode
1392 * Export mode ( contact, contribution, etc...).
1393 * @param string $componentTable
1394 * Name of temporary table
1396 * Array of object's ids
1400 public static function export(&$exportTempTable, &$headerRows, &$sqlColumns, $exportMode, $componentTable, $ids) {
1401 return self
::singleton()->invoke(['exportTempTable', 'headerRows', 'sqlColumns', 'exportMode', 'componentTable', 'ids'],
1402 $exportTempTable, $headerRows, $sqlColumns,
1403 $exportMode, $componentTable, $ids,
1409 * This hook allows modification of the queries constructed from dupe rules.
1411 * @param string $obj
1412 * Object of rulegroup class.
1413 * @param string $type
1414 * Type of queries e.g table / threshold.
1415 * @param array $query
1420 public static function dupeQuery($obj, $type, &$query) {
1421 return self
::singleton()->invoke(['obj', 'type', 'query'], $obj, $type, $query,
1422 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1428 * Check for duplicate contacts
1430 * @param array $dedupeParams
1431 * Array of params for finding duplicates: [
1432 * '{parameters returned by CRM_Dedupe_Finder::formatParams}
1433 * 'check_permission' => TRUE/FALSE;
1434 * 'contact_type' => $contactType;
1436 * 'rule_group_id' => $ruleGroupID;
1437 * 'excludedContactIDs' => $excludedContactIDs;
1438 * @param array $dedupeResults
1439 * Array of results ['handled' => TRUE/FALSE, 'ids' => array of IDs of duplicate contacts]
1440 * @param array $contextParams
1441 * The context if relevant, eg. ['event_id' => X]
1445 public static function findDuplicates($dedupeParams, &$dedupeResults, $contextParams) {
1446 return self
::singleton()
1447 ->invoke(['dedupeParams', 'dedupeResults', 'contextParams'], $dedupeParams, $dedupeResults, $contextParams, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_findDuplicates');
1451 * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php
1453 * @param string $type
1454 * Type of mail processed: 'activity' OR 'mailing'.
1455 * @param array &$params the params that were sent to the CiviCRM API function
1456 * @param object $mail
1457 * The mail object which is an ezcMail class.
1458 * @param array &$result the result returned by the api call
1459 * @param string $action
1460 * (optional ) the requested action to be performed if the types was 'mailing'.
1464 public static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) {
1465 return self
::singleton()
1466 ->invoke(['type', 'params', 'mail', 'result', 'action'], $type, $params, $mail, $result, $action, self
::$_nullObject, 'civicrm_emailProcessor');
1470 * This hook is called after a row has been processed and the
1471 * record (and associated records imported
1473 * @param string $object
1474 * Object being imported (for now Contact only, later Contribution, Activity,.
1475 * Participant and Member)
1476 * @param string $usage
1477 * Hook usage/location (for now process only, later mapping and others).
1478 * @param string $objectRef
1479 * Import record object.
1480 * @param array $params
1481 * Array with various key values: currently.
1482 * contactID - contact id
1483 * importID - row id in temp table
1484 * importTempTable - name of tempTable
1485 * fieldHeaders - field headers
1486 * fields - import fields
1490 public static function import($object, $usage, &$objectRef, &$params) {
1491 return self
::singleton()->invoke(['object', 'usage', 'objectRef', 'params'], $object, $usage, $objectRef, $params,
1492 self
::$_nullObject, self
::$_nullObject,
1498 * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission()
1499 * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php).
1501 * @param string $entity
1502 * The API entity (like contact).
1503 * @param string $action
1504 * The API action (like get).
1505 * @param array &$params the API parameters
1506 * @param array &$permissions the associative permissions array (probably to be altered by this hook)
1510 public static function alterAPIPermissions($entity, $action, &$params, &$permissions) {
1511 return self
::singleton()->invoke(['entity', 'action', 'params', 'permissions'], $entity, $action, $params, $permissions,
1512 self
::$_nullObject, self
::$_nullObject,
1513 'civicrm_alterAPIPermissions'
1518 * @param CRM_Core_DAO $dao
1522 public static function postSave(&$dao) {
1523 $hookName = 'civicrm_postSave_' . $dao->getTableName();
1524 return self
::singleton()->invoke(['dao'], $dao,
1525 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1531 * This hook allows user to customize context menu Actions on contact summary page.
1533 * @param array $actions
1534 * Array of all Actions in contextmenu.
1535 * @param int $contactID
1536 * ContactID for the summary page.
1540 public static function summaryActions(&$actions, $contactID = NULL) {
1541 return self
::singleton()->invoke(['actions', 'contactID'], $actions, $contactID,
1542 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1543 'civicrm_summaryActions'
1548 * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go.
1549 * This enables us hook implementors to modify both the headers and the rows
1551 * The BIGGEST drawback with this hook is that you may need to modify the result template to include your
1552 * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl
1554 * However, if you use the same number of columns, you can overwrite the existing columns with the values that
1555 * you want displayed. This is a hackish, but avoids template modification.
1557 * @param string $objectName
1558 * The component name that we are doing the search.
1559 * activity, campaign, case, contact, contribution, event, grant, membership, and pledge
1560 * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order )
1561 * @param array &$rows the list of values, an associate array with fields that are displayed for that component
1562 * @param array $selector
1563 * the selector object. Allows you access to the context of the search
1566 * modify the header and values object to pass the data you need
1568 public static function searchColumns($objectName, &$headers, &$rows, &$selector) {
1569 return self
::singleton()->invoke(['objectName', 'headers', 'rows', 'selector'], $objectName, $headers, $rows, $selector,
1570 self
::$_nullObject, self
::$_nullObject,
1571 'civicrm_searchColumns'
1576 * This hook is called when uf groups are being built for a module.
1578 * @param string $moduleName
1580 * @param array $ufGroups
1581 * Array of ufgroups for a module.
1585 public static function buildUFGroupsForModule($moduleName, &$ufGroups) {
1586 return self
::singleton()->invoke(['moduleName', 'ufGroups'], $moduleName, $ufGroups,
1587 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1588 'civicrm_buildUFGroupsForModule'
1593 * This hook is called when we are determining the contactID for a specific
1596 * @param string $email
1597 * The email address.
1598 * @param int $contactID
1599 * The contactID that matches this email address, IF it exists.
1600 * @param array $result
1601 * (reference) has two fields.
1602 * contactID - the new (or same) contactID
1603 * action - 3 possible values:
1604 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record
1605 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID
1606 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address
1610 public static function emailProcessorContact($email, $contactID, &$result) {
1611 return self
::singleton()->invoke(['email', 'contactID', 'result'], $email, $contactID, $result,
1612 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1613 'civicrm_emailProcessorContact'
1618 * Hook definition for altering the generation of Mailing Labels.
1620 * @param array $args
1621 * An array of the args in the order defined for the tcpdf multiCell api call.
1622 * with the variable names below converted into string keys (ie $w become 'w'
1623 * as the first key for $args)
1624 * float $w Width of cells. If 0, they extend up to the right margin of the page.
1625 * float $h Cell minimum height. The cell extends automatically if needed.
1626 * string $txt String to print
1627 * mixed $border Indicates if borders must be drawn around the cell block. The value can
1628 * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or
1629 * a string containing some or all of the following characters (in any order):
1630 * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
1631 * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string:
1632 * left align</li><li>C: center</li><li>R: right align</li><li>J: justification
1633 * (default value when $ishtml=false)</li></ul>
1634 * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
1635 * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0:
1636 * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul>
1637 * float $x x position in user units
1638 * float $y y position in user units
1639 * boolean $reseth if true reset the last cell height (default true).
1640 * int $stretch stretch character mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if
1641 * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if
1642 * necessary</li><li>4 = forced character spacing</li></ul>
1643 * boolean $ishtml set to true if $txt is HTML content (default = false).
1644 * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width.
1645 * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page,
1646 * or 0 for disable this feature. This feature works only when $ishtml=false.
1650 public static function alterMailingLabelParams(&$args) {
1651 return self
::singleton()->invoke(['args'], $args,
1652 self
::$_nullObject, self
::$_nullObject,
1653 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1654 'civicrm_alterMailingLabelParams'
1659 * This hooks allows alteration of generated page content.
1662 * Previously generated content.
1664 * Context of content - page or form.
1666 * The file name of the tpl.
1668 * A reference to the page or form object.
1672 public static function alterContent(&$content, $context, $tplName, &$object) {
1673 return self
::singleton()->invoke(['content', 'context', 'tplName', 'object'], $content, $context, $tplName, $object,
1674 self
::$_nullObject, self
::$_nullObject,
1675 'civicrm_alterContent'
1680 * This hooks allows alteration of the tpl file used to generate content. It differs from the
1681 * altercontent hook as the content has already been rendered through the tpl at that point
1684 * Previously generated content.
1686 * Reference to the form object.
1688 * Context of content - page or form.
1690 * Reference the file name of the tpl.
1694 public static function alterTemplateFile($formName, &$form, $context, &$tplName) {
1695 return self
::singleton()->invoke(['formName', 'form', 'context', 'tplName'], $formName, $form, $context, $tplName,
1696 self
::$_nullObject, self
::$_nullObject,
1697 'civicrm_alterTemplateFile'
1702 * This hook collects the trigger definition from all components.
1705 * @param string $tableName
1706 * (optional) the name of the table that we are interested in only.
1708 * @internal param \reference $triggerInfo to an array of trigger information
1709 * each element has 4 fields:
1710 * table - array of tableName
1711 * when - BEFORE or AFTER
1712 * event - array of eventName - INSERT OR UPDATE OR DELETE
1713 * sql - array of statements optionally terminated with a ;
1714 * a statement can use the tokes {tableName} and {eventName}
1715 * to do token replacement with the table / event. This allows
1716 * templatizing logging and other hooks
1719 public static function triggerInfo(&$info, $tableName = NULL) {
1720 return self
::singleton()->invoke(['info', 'tableName'], $info, $tableName,
1721 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1723 'civicrm_triggerInfo'
1728 * This hook allows changes to the spec of which tables to log.
1730 * @param array $logTableSpec
1734 public static function alterLogTables(&$logTableSpec) {
1735 return self
::singleton()->invoke(['logTableSpec'], $logTableSpec, $_nullObject,
1736 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1738 'civicrm_alterLogTables'
1743 * This hook is called when a module-extension is installed.
1744 * Each module will receive hook_civicrm_install during its own installation (but not during the
1745 * installation of unrelated modules).
1747 public static function install() {
1748 return self
::singleton()->invoke(0, self
::$_nullObject,
1749 self
::$_nullObject, self
::$_nullObject,
1750 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1756 * This hook is called when a module-extension is uninstalled.
1757 * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the
1758 * uninstallation of unrelated modules).
1760 public static function uninstall() {
1761 return self
::singleton()->invoke(0, self
::$_nullObject,
1762 self
::$_nullObject, self
::$_nullObject,
1763 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1769 * This hook is called when a module-extension is re-enabled.
1770 * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the
1771 * re-enablement of unrelated modules).
1773 public static function enable() {
1774 return self
::singleton()->invoke(0, self
::$_nullObject,
1775 self
::$_nullObject, self
::$_nullObject,
1776 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1782 * This hook is called when a module-extension is disabled.
1783 * Each module will receive hook_civicrm_disable during its own disablement (but not during the
1784 * disablement of unrelated modules).
1786 public static function disable() {
1787 return self
::singleton()->invoke(0, self
::$_nullObject,
1788 self
::$_nullObject, self
::$_nullObject,
1789 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1797 * This hook is called when the browser is being re-directed and allows the url
1800 * @param \Psr\Http\Message\UriInterface $url
1801 * @param array $context
1802 * Additional information about context
1803 * - output - if this is 'json' then it will return json.
1806 * the return value is ignored
1808 public static function alterRedirect(&$url, &$context) {
1809 return self
::singleton()->invoke(['url', 'context'], $url,
1810 $context, self
::$_nullObject,
1811 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1812 'civicrm_alterRedirect'
1823 public static function alterReportVar($varType, &$var, &$object) {
1824 return self
::singleton()->invoke(['varType', 'var', 'object'], $varType, $var, $object,
1826 self
::$_nullObject, self
::$_nullObject,
1827 'civicrm_alterReportVar'
1832 * This hook is called to drive database upgrades for extension-modules.
1835 * The type of operation being performed; 'check' or 'enqueue'.
1836 * @param CRM_Queue_Queue $queue
1837 * (for 'enqueue') the modifiable list of pending up upgrade tasks.
1840 * NULL, if $op is 'enqueue'.
1841 * TRUE, if $op is 'check' and upgrades are pending.
1842 * FALSE, if $op is 'check' and upgrades are not pending.
1844 public static function upgrade($op, CRM_Queue_Queue
$queue = NULL) {
1845 return self
::singleton()->invoke(['op', 'queue'], $op, $queue,
1846 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1853 * This hook is called when an email has been successfully sent by CiviCRM, but not on an error.
1855 * @param array $params
1856 * The mailing parameters. Array fields include: groupName, from, toName,
1857 * toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers,
1858 * attachments (array)
1862 public static function postEmailSend(&$params) {
1863 return self
::singleton()->invoke(['params'], $params,
1864 self
::$_nullObject, self
::$_nullObject,
1865 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1866 'civicrm_postEmailSend'
1871 * This hook is called when a CiviMail mailing has completed
1873 * @param int $mailingId
1878 public static function postMailing($mailingId) {
1879 return self
::singleton()->invoke(['mailingId'], $mailingId,
1880 self
::$_nullObject, self
::$_nullObject,
1881 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1882 'civicrm_postMailing'
1887 * This hook is called when Settings specifications are loaded.
1889 * @param array $settingsFolders
1890 * List of paths from which to derive metadata
1894 public static function alterSettingsFolders(&$settingsFolders) {
1895 return self
::singleton()->invoke(['settingsFolders'], $settingsFolders,
1896 self
::$_nullObject, self
::$_nullObject,
1897 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1898 'civicrm_alterSettingsFolders'
1903 * This hook is called when Settings have been loaded from the xml
1904 * It is an opportunity for hooks to alter the data
1906 * @param array $settingsMetaData
1907 * Settings Metadata.
1908 * @param int $domainID
1909 * @param mixed $profile
1913 public static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) {
1914 return self
::singleton()->invoke(['settingsMetaData', 'domainID', 'profile'], $settingsMetaData,
1915 $domainID, $profile,
1916 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1917 'civicrm_alterSettingsMetaData'
1922 * This hook is called before running an api call.
1924 * @param API_Wrapper[] $wrappers
1925 * (see CRM_Utils_API_ReloadOption as an example)
1926 * @param mixed $apiRequest
1929 * The return value is ignored
1931 public static function apiWrappers(&$wrappers, $apiRequest) {
1932 return self
::singleton()
1933 ->invoke(['wrappers', 'apiRequest'], $wrappers, $apiRequest, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1934 self
::$_nullObject, 'civicrm_apiWrappers'
1939 * This hook is called before running pending cron jobs.
1941 * @param CRM_Core_JobManager $jobManager
1944 * The return value is ignored.
1946 public static function cron($jobManager) {
1947 return self
::singleton()->invoke(['jobManager'],
1948 $jobManager, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1954 * This hook is called when loading CMS permissions; use this hook to modify
1955 * the array of system permissions for CiviCRM.
1957 * @param array $permissions
1958 * Array of permissions. See CRM_Core_Permission::getCorePermissions() for
1959 * the format of this array.
1962 * The return value is ignored
1964 public static function permission(&$permissions) {
1965 return self
::singleton()->invoke(['permissions'], $permissions,
1966 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1967 'civicrm_permission'
1972 * This hook is called when checking permissions; use this hook to dynamically
1973 * escalate user permissions in certain use cases (cf. CRM-19256).
1975 * @param string $permission
1976 * The name of an atomic permission, ie. 'access deleted contacts'
1977 * @param bool $granted
1978 * Whether this permission is currently granted. The hook can change this value.
1979 * @param int $contactId
1980 * Contact whose permissions we are checking (if null, assume current user).
1983 * The return value is ignored
1985 public static function permission_check($permission, &$granted, $contactId) {
1986 return self
::singleton()->invoke(['permission', 'granted', 'contactId'], $permission, $granted, $contactId,
1987 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1988 'civicrm_permission_check'
1993 * @param CRM_Core_Exception $exception
1994 * @param mixed $request
1995 * Reserved for future use.
1997 public static function unhandledException($exception, $request = NULL) {
1998 $event = new \Civi\Core\Event\
UnhandledExceptionEvent($exception, self
::$_nullObject);
1999 \Civi
::dispatcher()->dispatch('hook_civicrm_unhandled_exception', $event);
2003 * This hook is called for declaring managed entities via API.
2005 * Note: This is a pre-boot hook. It will dispatch via the extension/module
2006 * subsystem but *not* the Symfony EventDispatcher.
2008 * @param array[] $entityTypes
2009 * List of entity types; each entity-type is an array with keys:
2010 * - name: string, a unique short name (e.g. "ReportInstance")
2011 * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance")
2012 * - table: string, a SQL table name (e.g. "civicrm_report_instance")
2013 * - fields_callback: array, list of callables which manipulates field list
2014 * - links_callback: array, list of callables which manipulates fk list
2017 * The return value is ignored
2019 public static function entityTypes(&$entityTypes) {
2020 return self
::singleton()->invoke(['entityTypes'], $entityTypes, self
::$_nullObject, self
::$_nullObject,
2021 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_entityTypes'
2026 * Build a description of available hooks.
2028 * @param \Civi\Core\CiviEventInspector $inspector
2030 public static function eventDefs($inspector) {
2031 $event = \Civi\Core\Event\GenericHookEvent
::create([
2032 'inspector' => $inspector,
2034 Civi
::dispatcher()->dispatch('hook_civicrm_eventDefs', $event);
2038 * This hook is called while preparing a profile form.
2040 * @param string $profileName
2043 public static function buildProfile($profileName) {
2044 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2045 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildProfile');
2049 * This hook is called while validating a profile form submission.
2051 * @param string $profileName
2054 public static function validateProfile($profileName) {
2055 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2056 self
::$_nullObject, self
::$_nullObject, 'civicrm_validateProfile');
2060 * This hook is called processing a valid profile form submission.
2062 * @param string $profileName
2065 public static function processProfile($profileName) {
2066 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2067 self
::$_nullObject, self
::$_nullObject, 'civicrm_processProfile');
2071 * This hook is called while preparing a read-only profile screen
2073 * @param string $profileName
2076 public static function viewProfile($profileName) {
2077 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2078 self
::$_nullObject, self
::$_nullObject, 'civicrm_viewProfile');
2082 * This hook is called while preparing a list of contacts (based on a profile)
2084 * @param string $profileName
2087 public static function searchProfile($profileName) {
2088 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2089 self
::$_nullObject, self
::$_nullObject, 'civicrm_searchProfile');
2093 * This hook is invoked when building a CiviCRM name badge.
2095 * @param string $labelName
2096 * String referencing name of badge format.
2097 * @param object $label
2098 * Reference to the label object.
2099 * @param array $format
2100 * Array of format data.
2101 * @param array $participant
2102 * Array of participant values.
2105 * the return value is ignored
2107 public static function alterBadge($labelName, &$label, &$format, &$participant) {
2108 return self
::singleton()
2109 ->invoke(['labelName', 'label', 'format', 'participant'], $labelName, $label, $format, $participant, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBadge');
2113 * This hook is called before encoding data in barcode.
2115 * @param array $data
2116 * Associated array of values available for encoding.
2117 * @param string $type
2118 * Type of barcode, classic barcode or QRcode.
2119 * @param string $context
2120 * Where this hooks is invoked.
2124 public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') {
2125 return self
::singleton()->invoke(['data', 'type', 'context'], $data, $type, $context, self
::$_nullObject,
2126 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBarcode');
2130 * Modify or replace the Mailer object used for outgoing mail.
2132 * @param object $mailer
2133 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
2134 * @param string $driver
2135 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
2136 * @param array $params
2137 * The default mailer config options
2140 * @see Mail::factory
2142 public static function alterMailer(&$mailer, $driver, $params) {
2143 return self
::singleton()
2144 ->invoke(['mailer', 'driver', 'params'], $mailer, $driver, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterMailer');
2148 * This hook is called while building the core search query,
2149 * so hook implementers can provide their own query objects which alters/extends core search.
2151 * @param array $queryObjects
2152 * @param string $type
2156 public static function queryObjects(&$queryObjects, $type = 'Contact') {
2157 return self
::singleton()
2158 ->invoke(['queryObjects', 'type'], $queryObjects, $type, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_queryObjects');
2162 * This hook is called while viewing contact dashboard.
2164 * @param array $availableDashlets
2165 * List of dashlets; each is formatted per api/v3/Dashboard
2166 * @param array $defaultDashlets
2167 * List of dashlets; each is formatted per api/v3/DashboardContact
2171 public static function dashboard_defaults($availableDashlets, &$defaultDashlets) {
2172 return self
::singleton()
2173 ->invoke(['availableDashlets', 'defaultDashlets'], $availableDashlets, $defaultDashlets, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_dashboard_defaults');
2177 * This hook is called before a case merge (or a case reassign)
2179 * @param int $mainContactId
2180 * @param int $mainCaseId
2181 * @param int $otherContactId
2182 * @param int $otherCaseId
2183 * @param bool $changeClient
2187 public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
2188 return self
::singleton()
2189 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_pre_case_merge');
2193 * This hook is called after a case merge (or a case reassign)
2195 * @param int $mainContactId
2196 * @param int $mainCaseId
2197 * @param int $otherContactId
2198 * @param int $otherCaseId
2199 * @param bool $changeClient
2203 public static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
2204 return self
::singleton()
2205 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_post_case_merge');
2210 * Add a hook for altering the display name
2212 * hook_civicrm_contact_get_displayname(&$display_name, $objContact)
2214 * @param string $displayName
2215 * @param int $contactId
2216 * @param object $dao
2217 * The contact object.
2221 public static function alterDisplayName(&$displayName, $contactId, $dao) {
2222 return self
::singleton()->invoke(['displayName', 'contactId', 'dao'],
2223 $displayName, $contactId, $dao, self
::$_nullObject, self
::$_nullObject,
2224 self
::$_nullObject, 'civicrm_contact_get_displayname'
2229 * Modify the CRM_Core_Resources settings data.
2231 * @param array $data
2232 * @see CRM_Core_Resources::addSetting
2234 public static function alterResourceSettings(&$data) {
2235 $event = \Civi\Core\Event\GenericHookEvent
::create([
2238 Civi
::dispatcher()->dispatch('hook_civicrm_alterResourceSettings', $event);
2242 * EXPERIMENTAL: This hook allows one to register additional Angular modules
2244 * @param array $angularModules
2245 * List of modules. Each module defines:
2246 * - ext: string, the CiviCRM extension which hosts the files.
2247 * - js: array, list of JS files or globs.
2248 * - css: array, list of CSS files or globs.
2249 * - partials: array, list of base-dirs containing HTML.
2250 * - partialsCallback: mixed, a callback function which generates a list of HTML
2251 * function(string $moduleName, array $moduleDefn) => array(string $file => string $html)
2252 * For future-proofing, use a serializable callback (e.g. string/array).
2253 * See also: Civi\Core\Resolver.
2254 * - requires: array, list of required Angular modules.
2255 * - basePages: array, uncondtionally load this module onto the given Angular pages. [v4.7.21+]
2256 * If omitted, default to "array('civicrm/a')" for backward compat.
2257 * For a utility that should only be loaded on-demand, use "array()".
2258 * For a utility that should be loaded in all pages use, "array('*')".
2260 * the return value is ignored
2263 * function mymod_civicrm_angularModules(&$angularModules) {
2264 * $angularModules['myAngularModule'] = array(
2265 * 'ext' => 'org.example.mymod',
2266 * 'js' => array('js/myAngularModule.js'),
2268 * $angularModules['myBigAngularModule'] = array(
2269 * 'ext' => 'org.example.mymod',
2270 * 'js' => array('js/part1.js', 'js/part2.js', 'ext://other.ext.name/file.js', 'assetBuilder://dynamicAsset.js'),
2271 * 'css' => array('css/myAngularModule.css', 'ext://other.ext.name/file.css', 'assetBuilder://dynamicAsset.css'),
2272 * 'partials' => array('partials/myBigAngularModule'),
2273 * 'requires' => array('otherModuleA', 'otherModuleB'),
2274 * 'basePages' => array('civicrm/a'),
2279 public static function angularModules(&$angularModules) {
2280 return self
::singleton()->invoke(['angularModules'], $angularModules,
2281 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2282 'civicrm_angularModules'
2287 * Alter the definition of some Angular HTML partials.
2289 * @param \Civi\Angular\Manager $angular
2292 * function example_civicrm_alterAngular($angular) {
2293 * $changeSet = \Civi\Angular\ChangeSet::create('mychanges')
2294 * ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(phpQueryObject $doc) {
2295 * $doc->find('[ng-form="crmMailingSubform"]')->attr('cat-stevens', 'ts(\'wild world\')');
2298 * $angular->add($changeSet);
2302 public static function alterAngular($angular) {
2303 $event = \Civi\Core\Event\GenericHookEvent
::create([
2304 'angular' => $angular,
2306 Civi
::dispatcher()->dispatch('hook_civicrm_alterAngular', $event);
2310 * This hook is called when building a link to a semi-static asset.
2312 * @param string $asset
2313 * The name of the asset.
2314 * Ex: 'angular.json'
2315 * @param array $params
2316 * List of optional arguments which influence the content.
2318 * the return value is ignored
2320 public static function getAssetUrl(&$asset, &$params) {
2321 return self
::singleton()->invoke(['asset', 'params'],
2322 $asset, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2323 'civicrm_getAssetUrl'
2328 * This hook is called whenever the system builds a new copy of
2329 * semi-static asset.
2331 * @param string $asset
2332 * The name of the asset.
2333 * Ex: 'angular.json'
2334 * @param array $params
2335 * List of optional arguments which influence the content.
2336 * Note: Params are immutable because they are part of the cache-key.
2337 * @param string $mimeType
2338 * Initially, NULL. Modify to specify the mime-type.
2339 * @param string $content
2340 * Initially, NULL. Modify to specify the rendered content.
2342 * the return value is ignored
2344 public static function buildAsset($asset, $params, &$mimeType, &$content) {
2345 return self
::singleton()->invoke(['asset', 'params', 'mimeType', 'content'],
2346 $asset, $params, $mimeType, $content, self
::$_nullObject, self
::$_nullObject,
2347 'civicrm_buildAsset'
2352 * This hook fires whenever a record in a case changes.
2354 * @param \Civi\CCase\Analyzer $analyzer
2355 * A bundle of data about the case (such as the case and activity records).
2357 public static function caseChange(\Civi\CCase\Analyzer
$analyzer) {
2358 $event = new \Civi\CCase\Event\
CaseChangeEvent($analyzer);
2359 \Civi
::dispatcher()->dispatch('hook_civicrm_caseChange', $event);
2363 * Generate a default CRUD URL for an entity.
2365 * @param array $spec
2367 * - action: int, eg CRM_Core_Action::VIEW or CRM_Core_Action::UPDATE
2368 * - entity_table: string
2370 * @param CRM_Core_DAO $bao
2371 * @param array $link
2372 * To define the link, add these keys to $link:.
2376 * - url: string (used in lieu of "path"/"query")
2377 * Note: if making "url" CRM_Utils_System::url(), set $htmlize=false
2380 public static function crudLink($spec, $bao, &$link) {
2381 return self
::singleton()->invoke(['spec', 'bao', 'link'], $spec, $bao, $link,
2382 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2388 * Modify the CiviCRM container - add new services, parameters, extensions, etc.
2391 * use Symfony\Component\Config\Resource\FileResource;
2392 * use Symfony\Component\DependencyInjection\Definition;
2394 * function mymodule_civicrm_container($container) {
2395 * $container->addResource(new FileResource(__FILE__));
2396 * $container->setDefinition('mysvc', new Definition('My\Class', array()));
2400 * Tip: The container configuration will be compiled/cached. The default cache
2401 * behavior is aggressive. When you first implement the hook, be sure to
2402 * flush the cache. Additionally, you should relax caching during development.
2403 * In `civicrm.settings.php`, set define('CIVICRM_CONTAINER_CACHE', 'auto').
2405 * Note: This is a preboot hook. It will dispatch via the extension/module
2406 * subsystem but *not* the Symfony EventDispatcher.
2408 * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
2409 * @see http://symfony.com/doc/current/components/dependency_injection/index.html
2411 public static function container(\Symfony\Component\DependencyInjection\ContainerBuilder
$container) {
2412 self
::singleton()->invoke(['container'], $container, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_container');
2416 * @param array $fileSearches CRM_Core_FileSearchInterface
2419 public static function fileSearches(&$fileSearches) {
2420 return self
::singleton()->invoke(['fileSearches'], $fileSearches,
2421 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2422 'civicrm_fileSearches'
2427 * Check system status.
2429 * @param array $messages
2430 * Array<CRM_Utils_Check_Message>. A list of messages regarding system status.
2433 public static function check(&$messages) {
2434 return self
::singleton()
2435 ->invoke(['messages'], $messages, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_check');
2439 * This hook is called when a query string of the CSV Batch export is generated.
2441 * @param string $query
2445 public static function batchQuery(&$query) {
2446 return self
::singleton()->invoke(['query'], $query, self
::$_nullObject,
2447 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2448 'civicrm_batchQuery'
2453 * This hook is called to alter Deferred revenue item values just before they are
2454 * inserted in civicrm_financial_trxn table
2456 * @param array $deferredRevenues
2458 * @param array $contributionDetails
2460 * @param bool $update
2462 * @param string $context
2466 public static function alterDeferredRevenueItems(&$deferredRevenues, $contributionDetails, $update, $context) {
2467 return self
::singleton()->invoke(['deferredRevenues', 'contributionDetails', 'update', 'context'], $deferredRevenues, $contributionDetails, $update, $context,
2468 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterDeferredRevenueItems'
2473 * This hook is called when the entries of the CSV Batch export are mapped.
2475 * @param array $results
2476 * @param array $items
2480 public static function batchItems(&$results, &$items) {
2481 return self
::singleton()->invoke(['results', 'items'], $results, $items,
2482 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2483 'civicrm_batchItems'
2488 * This hook is called when core resources are being loaded
2490 * @see CRM_Core_Resources::coreResourceList
2492 * @param array $list
2493 * @param string $region
2495 public static function coreResourceList(&$list, $region) {
2496 self
::singleton()->invoke(['list', 'region'], $list, $region,
2497 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2498 'civicrm_coreResourceList'
2503 * Allows the list of filters on the EntityRef widget to be altered.
2505 * @see CRM_Core_Resources::entityRefFilters
2507 * @param array $filters
2508 * @param array $links
2510 public static function entityRefFilters(&$filters, &$links = NULL) {
2511 self
::singleton()->invoke(['filters', 'links'], $filters, $links, self
::$_nullObject,
2512 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2513 'civicrm_entityRefFilters'
2518 * This hook is called for bypass a few civicrm urls from IDS check.
2520 * @param array $skip list of civicrm urls
2524 public static function idsException(&$skip) {
2525 return self
::singleton()->invoke(['skip'], $skip, self
::$_nullObject,
2526 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2527 'civicrm_idsException'
2532 * This hook is called when a geocoder's format method is called.
2534 * @param string $geoProvider
2535 * @param array $values
2536 * @param SimpleXMLElement $xml
2540 public static function geocoderFormat($geoProvider, &$values, $xml) {
2541 return self
::singleton()->invoke(['geoProvider', 'values', 'xml'], $geoProvider, $values, $xml,
2542 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2543 'civicrm_geocoderFormat'
2548 * This hook is called before an inbound SMS is processed.
2550 * @param \CRM_SMS_Message $message
2551 * An SMS message received
2554 public static function inboundSMS(&$message) {
2555 return self
::singleton()->invoke(['message'], $message, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_inboundSMS');
2559 * This hook is called to modify api params of EntityRef form field
2561 * @param array $params
2562 * @param string $formName
2565 public static function alterEntityRefParams(&$params, $formName) {
2566 return self
::singleton()->invoke(['params', 'formName'], $params, $formName,
2567 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2568 'civicrm_alterEntityRefParams'
2573 * This hook is called before a scheduled job is executed
2575 * @param CRM_Core_DAO_Job $job
2576 * The job to be executed
2577 * @param array $params
2578 * The arguments to be given to the job
2580 public static function preJob($job, $params) {
2581 return self
::singleton()->invoke(['job', 'params'], $job, $params,
2582 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2588 * This hook is called after a scheduled job is executed
2590 * @param CRM_Core_DAO_Job $job
2591 * The job that was executed
2592 * @param array $params
2593 * The arguments given to the job
2594 * @param array $result
2595 * The result of the API call, or the thrown exception if any
2597 public static function postJob($job, $params, $result) {
2598 return self
::singleton()->invoke(['job', 'params', 'result'], $job, $params, $result,
2599 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2605 * This hook is called before and after constructing mail recipients.
2606 * Allows user to alter filter and/or search query to fetch mail recipients
2608 * @param CRM_Mailing_DAO_Mailing $mailingObject
2609 * @param array $criteria
2610 * A list of SQL criteria; you can add/remove/replace/modify criteria.
2611 * Array(string $name => CRM_Utils_SQL_Select $criterion).
2612 * Ex: array('do_not_email' => CRM_Utils_SQL_Select::fragment()->where("$contact.do_not_email = 0")).
2613 * @param string $context
2617 public static function alterMailingRecipients(&$mailingObject, &$criteria, $context) {
2618 return self
::singleton()->invoke(['mailingObject', 'params', 'context'],
2619 $mailingObject, $criteria, $context,
2620 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2621 'civicrm_alterMailingRecipients'
2626 * ALlow Extensions to custom process IPN hook data such as sending Google Analyitcs information based on the IPN
2627 * @param array $IPNData - Array of IPN Data
2630 public static function postIPNProcess(&$IPNData) {
2631 return self
::singleton()->invoke(['IPNData'],
2632 $IPNData, self
::$_nullObject, self
::$_nullObject,
2633 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2634 'civicrm_postIPNProcess'
2639 * Allow extensions to modify the array of acceptable fields to be included on profiles
2640 * @param array $fields
2641 * format is [Entity => array of DAO fields]
2644 public static function alterUFFields(&$fields) {
2645 return self
::singleton()->invoke(['fields'],
2646 $fields, self
::$_nullObject, self
::$_nullObject,
2647 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2648 'civicrm_alterUFFields'
2653 * This hook is called to alter Custom field value before its displayed.
2655 * @param string $displayValue
2656 * @param mixed $value
2657 * @param int $entityId
2658 * @param array $fieldInfo
2662 public static function alterCustomFieldDisplayValue(&$displayValue, $value, $entityId, $fieldInfo) {
2663 return self
::singleton()->invoke(
2664 ['displayValue', 'value', 'entityId', 'fieldInfo'],
2665 $displayValue, $value, $entityId, $fieldInfo, self
::$_nullObject,
2666 self
::$_nullObject, 'civicrm_alterCustomFieldDisplayValue'