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'];
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 retrieves links from other modules and injects it into.
397 * the view contact tabs
400 * The type of operation being performed.
401 * @param string $objectName
402 * The name of the object.
403 * @param int $objectId
404 * The unique identifier for the object.
405 * @param array $links
406 * (optional) the links array (introduced in v3.2).
408 * (optional) the bitmask to show/hide links.
409 * @param array $values
410 * (optional) the values to fill the links.
413 * the return value is ignored
415 public static function links($op, $objectName, &$objectId, &$links, &$mask = NULL, &$values = []) {
416 return self
::singleton()->invoke(['op', 'objectName', 'objectId', 'links', 'mask', 'values'], $op, $objectName, $objectId, $links, $mask, $values, 'civicrm_links');
420 * This hook is invoked during the CiviCRM form preProcess phase.
422 * @param string $formName
423 * The name of the form.
424 * @param CRM_Core_Form $form
425 * Reference to the form object.
428 * the return value is ignored
430 public static function preProcess($formName, &$form) {
431 return self
::singleton()
432 ->invoke(['formName', 'form'], $formName, $form, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_preProcess');
436 * This hook is invoked when building a CiviCRM form. This hook should also
437 * be used to set the default values of a form element
439 * @param string $formName
440 * The name of the form.
441 * @param CRM_Core_Form $form
442 * Reference to the form object.
445 * the return value is ignored
447 public static function buildForm($formName, &$form) {
448 return self
::singleton()->invoke(['formName', 'form'], $formName, $form,
449 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
455 * This hook is invoked when a CiviCRM form is submitted. If the module has injected
456 * any form elements, this hook should save the values in the database
458 * @param string $formName
459 * The name of the form.
460 * @param CRM_Core_Form $form
461 * Reference to the form object.
464 * the return value is ignored
466 public static function postProcess($formName, &$form) {
467 return self
::singleton()->invoke(['formName', 'form'], $formName, $form,
468 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
469 'civicrm_postProcess'
474 * This hook is invoked during all CiviCRM form validation. An array of errors
475 * detected is returned. Else we assume validation succeeded.
477 * @param string $formName
478 * The name of the form.
479 * @param array &$fields the POST parameters as filtered by QF
480 * @param array &$files the FILES parameters as sent in by POST
481 * @param array &$form the form object
482 * @param array &$errors the array of errors.
485 * formRule hooks return a boolean or
486 * an array of error messages which display a QF Error
488 public static function validateForm($formName, &$fields, &$files, &$form, &$errors) {
489 return self
::singleton()
490 ->invoke(['formName', 'fields', 'files', 'form', 'errors'],
491 $formName, $fields, $files, $form, $errors, self
::$_nullObject, 'civicrm_validateForm');
495 * This hook is called after a db write on a custom table.
498 * The type of operation being performed.
499 * @param string $groupID
500 * The custom group ID.
501 * @param object $entityID
502 * The entityID of the row in the custom table.
503 * @param array $params
504 * The parameters that were sent into the calling function.
507 * the return value is ignored
509 public static function custom($op, $groupID, $entityID, &$params) {
510 return self
::singleton()
511 ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_custom');
515 * This hook is called when composing the ACL where clause to restrict
516 * visibility of contacts to the logged in user
519 * The type of permission needed.
520 * @param array $tables
521 * (reference ) add the tables that are needed for the select clause.
522 * @param array $whereTables
523 * (reference ) add the tables that are needed for the where clause.
524 * @param int $contactID
525 * The contactID for whom the check is made.
526 * @param string $where
527 * The currrent where clause.
530 * the return value is ignored
532 public static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) {
533 return self
::singleton()
534 ->invoke(['type', 'tables', 'whereTables', 'contactID', 'where'], $type, $tables, $whereTables, $contactID, $where, self
::$_nullObject, 'civicrm_aclWhereClause');
538 * This hook is called when composing the ACL where clause to restrict
539 * visibility of contacts to the logged in user
542 * The type of permission needed.
543 * @param int $contactID
544 * The contactID for whom the check is made.
545 * @param string $tableName
546 * The tableName which is being permissioned.
547 * @param array $allGroups
548 * The set of all the objects for the above table.
549 * @param array $currentGroups
550 * The set of objects that are currently permissioned for this contact.
553 * the return value is ignored
555 public static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) {
556 return self
::singleton()
557 ->invoke(['type', 'contactID', 'tableName', 'allGroups', 'currentGroups'], $type, $contactID, $tableName, $allGroups, $currentGroups, self
::$_nullObject, 'civicrm_aclGroup');
561 * @param string|CRM_Core_DAO $entity
562 * @param array $clauses
565 public static function selectWhereClause($entity, &$clauses) {
566 $entityName = is_object($entity) ?
_civicrm_api_get_entity_name_from_dao($entity) : $entity;
567 return self
::singleton()->invoke(['entity', 'clauses'], $entityName, $clauses,
568 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
569 'civicrm_selectWhereClause'
574 * This hook is called when building the menu table.
576 * @param array $files
577 * The current set of files to process.
580 * the return value is ignored
582 public static function xmlMenu(&$files) {
583 return self
::singleton()->invoke(['files'], $files,
584 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
590 * (Experimental) This hook is called when build the menu table.
592 * @param array $items
593 * List of records to include in menu table.
595 * the return value is ignored
597 public static function alterMenu(&$items) {
598 return self
::singleton()->invoke(['items'], $items,
599 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
605 * A theme is a set of CSS files which are loaded on CiviCRM pages. To register a new
606 * theme, add it to the $themes array. Use these properties:
608 * - ext: string (required)
609 * The full name of the extension which defines the theme.
610 * Ex: "org.civicrm.themes.greenwich".
611 * - title: string (required)
613 * - help: string (optional)
614 * Description of the theme's appearance.
615 * - url_callback: mixed (optional)
616 * A function ($themes, $themeKey, $cssExt, $cssFile) which returns the URL(s) for a CSS resource.
617 * Returns either an array of URLs or PASSTHRU.
618 * Ex: \Civi\Core\Themes\Resolvers::simple (default)
619 * Ex: \Civi\Core\Themes\Resolvers::none
620 * - prefix: string (optional)
621 * A prefix within the extension folder to prepend to the file name.
622 * - search_order: array (optional)
623 * A list of themes to search.
624 * Generally, the last theme should be "*fallback*" (Civi\Core\Themes::FALLBACK).
625 * - excludes: array (optional)
626 * A list of files (eg "civicrm:css/bootstrap.css" or "$ext:$file") which should never
627 * be returned (they are excluded from display).
629 * @param array $themes
630 * List of themes, keyed by name.
632 * the return value is ignored
634 public static function themes(&$themes) {
635 return self
::singleton()->invoke(1, $themes,
636 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
642 * The activeTheme hook determines which theme is active.
644 * @param string $theme
645 * The identifier for the theme. Alterable.
647 * @param array $context
648 * Information about the current page-request. Includes some mix of:
649 * - page: the relative path of the current Civi page (Ex: 'civicrm/dashboard').
650 * - themes: an instance of the Civi\Core\Themes service.
652 * the return value is ignored
654 public static function activeTheme(&$theme, $context) {
655 return self
::singleton()->invoke(array('theme', 'context'), $theme, $context,
656 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
657 'civicrm_activeTheme'
662 * This hook is called for declaring managed entities via API.
664 * @param array $entities
665 * List of pending entities. Each entity is an array with keys:
666 * + '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")
667 * + 'name': string, a symbolic name which can be used to track this entity (Note: Each module creates its own namespace)
668 * + 'entity': string, an entity-type supported by the CiviCRM API (Note: this currently must be an entity which supports the 'is_active' property)
669 * + 'params': array, the entity data as supported by the CiviCRM API
670 * + 'update' (v4.5+): string, a policy which describes when to update records
671 * - 'always' (default): always update the managed-entity record; changes in $entities will override any local changes (eg by the site-admin)
672 * - 'never': never update the managed-entity record; changes made locally (eg by the site-admin) will override changes in $entities
673 * + '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)
674 * - 'always' (default): always delete orphaned records
675 * - 'never': never delete orphaned records
676 * - '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.)
679 * the return value is ignored
681 public static function managed(&$entities) {
682 return self
::singleton()->invoke(['entities'], $entities,
683 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
689 * This hook is called when rendering the dashboard (q=civicrm/dashboard)
691 * @param int $contactID
692 * The contactID for whom the dashboard is being rendered.
693 * @param int $contentPlacement
694 * (output parameter) where should the hook content be displayed.
695 * relative to the activity list
698 * the html snippet to include in the dashboard
700 public static function dashboard($contactID, &$contentPlacement = self
::DASHBOARD_BELOW
) {
701 $retval = self
::singleton()->invoke(['contactID', 'contentPlacement'], $contactID, $contentPlacement,
702 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
707 * Note we need this seemingly unnecessary code because in the event that the implementation
708 * of the hook declares the second parameter but doesn't set it, then it comes back unset even
709 * though we have a default value in this function's declaration above.
711 if (!isset($contentPlacement)) {
712 $contentPlacement = self
::DASHBOARD_BELOW
;
719 * This hook is called before storing recently viewed items.
721 * @param array $recentArray
722 * An array of recently viewed or processed items, for in place modification.
726 public static function recent(&$recentArray) {
727 return self
::singleton()->invoke(['recentArray'], $recentArray,
728 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
734 * Determine how many other records refer to a given record.
736 * @param CRM_Core_DAO $dao
737 * The item for which we want a reference count.
738 * @param array $refCounts
739 * Each item in the array is an Array with keys:
740 * - name: string, eg "sql:civicrm_email:contact_id"
741 * - type: string, eg "sql"
742 * - count: int, eg "5" if there are 5 email addresses that refer to $dao
745 * Return is not really intended to be used.
747 public static function referenceCounts($dao, &$refCounts) {
748 return self
::singleton()->invoke(['dao', 'refCounts'], $dao, $refCounts,
749 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
750 'civicrm_referenceCounts'
755 * This hook is called when building the amount structure for a Contribution or Event Page.
757 * @param int $pageType
758 * Is this a contribution or event page.
759 * @param CRM_Core_Form $form
760 * Reference to the form object.
761 * @param array $amount
762 * The amount structure to be displayed.
766 public static function buildAmount($pageType, &$form, &$amount) {
767 return self
::singleton()->invoke(['pageType', 'form', 'amount'], $pageType, $form, $amount, self
::$_nullObject,
768 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildAmount');
772 * This hook is called when building the state list for a particular country.
774 * @param array $countryID
775 * The country id whose states are being selected.
780 public static function buildStateProvinceForCountry($countryID, &$states) {
781 return self
::singleton()->invoke(['countryID', 'states'], $countryID, $states,
782 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
783 'civicrm_buildStateProvinceForCountry'
788 * This hook is called when rendering the tabs for a contact (q=civicrm/contact/view)c
791 * The array of tabs that will be displayed.
792 * @param int $contactID
793 * The contactID for whom the dashboard is being rendered.
796 * @deprecated Use tabset() instead.
798 public static function tabs(&$tabs, $contactID) {
799 return self
::singleton()->invoke(['tabs', 'contactID'], $tabs, $contactID,
800 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabs'
805 * This hook is called when rendering the tabs used for events and potentially
806 * contribution pages, etc.
808 * @param string $tabsetName
809 * Name of the screen or visual element.
811 * Tabs that will be displayed.
812 * @param array $context
813 * Extra data about the screen or context in which the tab is used.
817 public static function tabset($tabsetName, &$tabs, $context) {
818 return self
::singleton()->invoke(['tabsetName', 'tabs', 'context'], $tabsetName, $tabs,
819 $context, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabset'
824 * This hook is called when sending an email / printing labels
826 * @param array $tokens
827 * The list of tokens that can be used for the contact.
831 public static function tokens(&$tokens) {
832 return self
::singleton()->invoke(['tokens'], $tokens,
833 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tokens'
838 * This hook allows modification of the admin panels
840 * @param array $panels
841 * Associated array of admin panels
845 public static function alterAdminPanel(&$panels) {
846 return self
::singleton()->invoke(array('panels'), $panels,
847 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
848 'civicrm_alterAdminPanel'
853 * This hook is called when sending an email / printing labels to get the values for all the
854 * tokens returned by the 'tokens' hook
856 * @param array $details
857 * The array to store the token values indexed by contactIDs (unless it a single).
858 * @param array $contactIDs
859 * An array of contactIDs.
861 * The jobID if this is associated with a CiviMail mailing.
862 * @param array $tokens
863 * The list of tokens associated with the content.
864 * @param string $className
865 * The top level className from where the hook is invoked.
869 public static function tokenValues(
876 return self
::singleton()
877 ->invoke(['details', 'contactIDs', 'jobID', 'tokens', 'className'], $details, $contactIDs, $jobID, $tokens, $className, self
::$_nullObject, 'civicrm_tokenValues');
881 * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables
884 * @param object $page
885 * The page that will be rendered.
889 public static function pageRun(&$page) {
890 return self
::singleton()->invoke(['page'], $page,
891 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
897 * This hook is called after a copy of an object has been made. The current objects are
898 * Event, Contribution Page and UFGroup
900 * @param string $objectName
901 * Name of the object.
902 * @param object $object
903 * Reference to the copy.
907 public static function copy($objectName, &$object) {
908 return self
::singleton()->invoke(['objectName', 'object'], $objectName, $object,
909 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
915 * This hook is called when a contact unsubscribes from a mailing. It allows modules
916 * to override what the contacts are removed from.
920 * @param int $mailingId
921 * The id of the mailing to unsub from
922 * @param int $contactId
923 * The id of the contact who is unsubscribing
924 * @param array|int $groups
925 * Groups the contact will be removed from.
926 * @param array|int $baseGroups
927 * Base groups (used in smart mailings) the contact will be removed from.
932 public static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) {
933 return self
::singleton()
934 ->invoke(['op', 'mailingId', 'contactId', 'groups', 'baseGroups'], $op, $mailingId, $contactId, $groups, $baseGroups, self
::$_nullObject, 'civicrm_unsubscribeGroups');
938 * This hook is called when CiviCRM needs to edit/display a custom field with options
940 * @deprecated in favor of hook_civicrm_fieldOptions
942 * @param int $customFieldID
943 * The custom field ID.
944 * @param array $options
945 * The current set of options for that custom field.
946 * You can add/remove existing options.
947 * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important
948 * to be careful to not overwrite the array.
949 * Only add/edit/remove the specific field options you intend to affect.
950 * @param bool $detailedFormat
951 * If true, the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format
952 * @param array $selectAttributes
953 * Contain select attribute(s) if any.
957 public static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE, $selectAttributes = []) {
958 // Weird: $selectAttributes is inputted but not outputted.
959 return self
::singleton()->invoke(['customFieldID', 'options', 'detailedFormat'], $customFieldID, $options, $detailedFormat,
960 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
961 'civicrm_customFieldOptions'
966 * Hook for modifying field options
968 * @param string $entity
969 * @param string $field
970 * @param array $options
971 * @param array $params
975 public static function fieldOptions($entity, $field, &$options, $params) {
976 return self
::singleton()->invoke(['entity', 'field', 'options', 'params'], $entity, $field, $options, $params,
977 self
::$_nullObject, self
::$_nullObject,
978 'civicrm_fieldOptions'
984 * This hook is called to display the list of actions allowed after doing a search.
985 * This allows the module developer to inject additional actions or to remove existing actions.
987 * @param string $objectType
988 * The object type for this search.
989 * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported.
990 * @param array $tasks
991 * The current set of tasks for that custom field.
992 * You can add/remove existing tasks.
993 * Each task needs to have a title (eg 'title' => ts( 'Group - add contacts')) and a class
994 * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
995 * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
996 * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be
997 * found in CRM/$objectType/Task.php.
1001 public static function searchTasks($objectType, &$tasks) {
1002 return self
::singleton()->invoke(['objectType', 'tasks'], $objectType, $tasks,
1003 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1004 'civicrm_searchTasks'
1009 * @param mixed $form
1010 * @param array $params
1014 public static function eventDiscount(&$form, &$params) {
1015 return self
::singleton()->invoke(['form', 'params'], $form, $params,
1016 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1017 'civicrm_eventDiscount'
1022 * This hook is called when composing a mailing. You can include / exclude other groups as needed.
1024 * @param mixed $form
1025 * The form object for which groups / mailings being displayed
1026 * @param array $groups
1027 * The list of groups being included / excluded
1028 * @param array $mailings
1029 * The list of mailings being included / excluded
1033 public static function mailingGroups(&$form, &$groups, &$mailings) {
1034 return self
::singleton()->invoke(['form', 'groups', 'mailings'], $form, $groups, $mailings,
1035 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1036 'civicrm_mailingGroups'
1041 * (Experimental) Modify the list of template-types used for CiviMail composition.
1043 * @param array $types
1044 * Sequentially indexed list of template types. Each type specifies:
1046 * - editorUrl: string, Angular template URL
1047 * - weight: int, priority when picking a default value for new mailings
1050 public static function mailingTemplateTypes(&$types) {
1051 return self
::singleton()->invoke(['types'], $types, self
::$_nullObject, self
::$_nullObject,
1052 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1053 'civicrm_mailingTemplateTypes'
1058 * This hook is called when composing the array of membershipTypes and their cost during a membership registration
1060 * Note the hook is called on initial page load and also reloaded after submit (PRG pattern).
1061 * You can use it to alter the membership types when first loaded, or after submission
1062 * (for example if you want to gather data in the form and use it to alter the fees).
1064 * @param mixed $form
1065 * The form object that is presenting the page
1066 * @param array $membershipTypes
1067 * The array of membership types and their amount
1071 public static function membershipTypeValues(&$form, &$membershipTypes) {
1072 return self
::singleton()->invoke(['form', 'membershipTypes'], $form, $membershipTypes,
1073 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1074 'civicrm_membershipTypeValues'
1079 * This hook is called when rendering the contact summary.
1081 * @param int $contactID
1082 * The contactID for whom the summary is being rendered
1083 * @param mixed $content
1084 * @param int $contentPlacement
1085 * Specifies where the hook content should be displayed relative to the
1089 * The html snippet to include in the contact summary
1091 public static function summary($contactID, &$content, &$contentPlacement = self
::SUMMARY_BELOW
) {
1092 return self
::singleton()->invoke(['contactID', 'content', 'contentPlacement'], $contactID, $content, $contentPlacement,
1093 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1099 * Use this hook to populate the list of contacts returned by Contact Reference custom fields.
1100 * By default, Contact Reference fields will search on and return all CiviCRM contacts.
1101 * If you want to limit the contacts returned to a specific group, or some other criteria
1102 * - you can override that behavior by providing a SQL query that returns some subset of your contacts.
1103 * The hook is called when the query is executed to get the list of contacts to display.
1105 * @param mixed $query
1106 * - the query that will be executed (input and output parameter);.
1107 * It's important to realize that the ACL clause is built prior to this hook being fired,
1108 * so your query will ignore any ACL rules that may be defined.
1109 * Your query must return two columns:
1110 * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data')
1112 * @param string $queryText
1113 * The name string to execute the query against (this is the value being typed in by the user).
1114 * @param string $context
1115 * The context in which this ajax call is being made (for example: 'customfield', 'caseview').
1117 * The id of the object for which the call is being made.
1118 * For custom fields, it will be the custom field id
1122 public static function contactListQuery(&$query, $queryText, $context, $id) {
1123 return self
::singleton()->invoke(['query', 'queryText', 'context', 'id'], $query, $queryText, $context, $id,
1124 self
::$_nullObject, self
::$_nullObject,
1125 'civicrm_contactListQuery'
1130 * Hook definition for altering payment parameters before talking to a payment processor back end.
1132 * Definition will look like this:
1134 * function hook_civicrm_alterPaymentProcessorParams(
1140 * @param CRM_Core_Payment $paymentObj
1141 * Instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy')
1142 * See discussion in CRM-16224 as to whether $paymentObj should be passed by reference.
1143 * @param array &$rawParams
1144 * array of params as passed to to the processor
1145 * @param array &$cookedParams
1146 * params after the processor code has translated them into its own key/value pairs
1149 * This return is not really intended to be used.
1151 public static function alterPaymentProcessorParams(
1156 return self
::singleton()->invoke(['paymentObj', 'rawParams', 'cookedParams'], $paymentObj, $rawParams, $cookedParams,
1157 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1158 'civicrm_alterPaymentProcessorParams'
1163 * This hook is called when an email is about to be sent by CiviCRM.
1165 * @param array $params
1166 * Array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html,
1167 * returnPath, replyTo, headers, attachments (array)
1168 * @param string $context
1169 * The context in which the hook is being invoked, eg 'civimail'.
1173 public static function alterMailParams(&$params, $context = NULL) {
1174 return self
::singleton()->invoke(['params', 'context'], $params, $context,
1175 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1176 'civicrm_alterMailParams'
1181 * This hook is called when membership status is being calculated.
1183 * @param array $membershipStatus
1184 * Membership status details as determined - alter if required.
1185 * @param array $arguments
1186 * Arguments passed in to calculate date.
1191 * - 'exclude_is_admin'
1192 * - 'membership_type_id'
1193 * @param array $membership
1194 * Membership details from the calling function.
1198 public static function alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) {
1199 return self
::singleton()->invoke(['membershipStatus', 'arguments', 'membership'], $membershipStatus, $arguments,
1200 $membership, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1201 'civicrm_alterCalculatedMembershipStatus'
1206 * This hook is called after getting the content of the mail and before tokenizing it.
1208 * @param array $content
1209 * Array fields include: html, text, subject
1213 public static function alterMailContent(&$content) {
1214 return self
::singleton()->invoke(['content'], $content,
1215 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1216 'civicrm_alterMailContent'
1221 * This hook is called when rendering the Manage Case screen.
1223 * @param int $caseID
1227 * Array of data to be displayed, where the key is a unique id to be used for styling (div id's)
1228 * and the value is an array with keys 'label' and 'value' specifying label/value pairs
1230 public static function caseSummary($caseID) {
1231 return self
::singleton()->invoke(['caseID'], $caseID,
1232 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1233 'civicrm_caseSummary'
1238 * This hook is called when locating CiviCase types.
1240 * @param array $caseTypes
1244 public static function caseTypes(&$caseTypes) {
1245 return self
::singleton()
1246 ->invoke(['caseTypes'], $caseTypes, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_caseTypes');
1250 * This hook is called soon after the CRM_Core_Config object has ben initialized.
1251 * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically.
1253 * @param CRM_Core_Config|array $config
1258 public static function config(&$config) {
1259 return self
::singleton()->invoke(['config'], $config,
1260 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1266 * This hooks allows to change option values.
1268 * @deprecated in favor of hook_civicrm_fieldOptions
1270 * @param array $options
1271 * Associated array of option values / id
1272 * @param string $groupName
1277 public static function optionValues(&$options, $groupName) {
1278 return self
::singleton()->invoke(['options', 'groupName'], $options, $groupName,
1279 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1280 'civicrm_optionValues'
1285 * This hook allows modification of the navigation menu.
1287 * @param array $params
1288 * Associated array of navigation menu entry to Modify/Add
1292 public static function navigationMenu(&$params) {
1293 return self
::singleton()->invoke(['params'], $params,
1294 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1295 'civicrm_navigationMenu'
1300 * This hook allows modification of the data used to perform merging of duplicates.
1302 * @param string $type
1303 * The type of data being passed (cidRefs|eidRefs|relTables|sqls).
1304 * @param array $data
1305 * The data, as described in $type.
1306 * @param int $mainId
1307 * Contact_id of the contact that survives the merge.
1308 * @param int $otherId
1309 * Contact_id of the contact that will be absorbed and deleted.
1310 * @param array $tables
1311 * When $type is "sqls", an array of tables as it may have been handed to the calling function.
1315 public static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) {
1316 return self
::singleton()->invoke(['type', 'data', 'mainId', 'otherId', 'tables'], $type, $data, $mainId, $otherId, $tables, self
::$_nullObject, 'civicrm_merge');
1320 * This hook allows modification of the data calculated for merging locations.
1322 * @param array $blocksDAO
1323 * Array of location DAO to be saved. These are arrays in 2 keys 'update' & 'delete'.
1324 * @param int $mainId
1325 * Contact_id of the contact that survives the merge.
1326 * @param int $otherId
1327 * Contact_id of the contact that will be absorbed and deleted.
1328 * @param array $migrationInfo
1329 * Calculated migration info, informational only.
1333 public static function alterLocationMergeData(&$blocksDAO, $mainId, $otherId, $migrationInfo) {
1334 return self
::singleton()->invoke(['blocksDAO', 'mainId', 'otherId', 'migrationInfo'], $blocksDAO, $mainId, $otherId, $migrationInfo, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterLocationMergeData');
1338 * This hook provides a way to override the default privacy behavior for notes.
1340 * @param array &$noteValues
1341 * Associative array of values for this note
1345 public static function notePrivacy(&$noteValues) {
1346 return self
::singleton()->invoke(['noteValues'], $noteValues,
1347 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1348 'civicrm_notePrivacy'
1353 * This hook is called before record is exported as CSV.
1355 * @param string $exportTempTable
1356 * Name of the temporary export table used during export.
1357 * @param array $headerRows
1358 * Header rows for output.
1359 * @param array $sqlColumns
1361 * @param int $exportMode
1362 * Export mode ( contact, contribution, etc...).
1363 * @param string $componentTable
1364 * Name of temporary table
1366 * Array of object's ids
1370 public static function export(&$exportTempTable, &$headerRows, &$sqlColumns, $exportMode, $componentTable, $ids) {
1371 return self
::singleton()->invoke(['exportTempTable', 'headerRows', 'sqlColumns', 'exportMode', 'componentTable', 'ids'],
1372 $exportTempTable, $headerRows, $sqlColumns,
1373 $exportMode, $componentTable, $ids,
1379 * This hook allows modification of the queries constructed from dupe rules.
1381 * @param string $obj
1382 * Object of rulegroup class.
1383 * @param string $type
1384 * Type of queries e.g table / threshold.
1385 * @param array $query
1390 public static function dupeQuery($obj, $type, &$query) {
1391 return self
::singleton()->invoke(['obj', 'type', 'query'], $obj, $type, $query,
1392 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1398 * Check for duplicate contacts
1400 * @param array $dedupeParams
1401 * Array of params for finding duplicates: [
1402 * '{parameters returned by CRM_Dedupe_Finder::formatParams}
1403 * 'check_permission' => TRUE/FALSE;
1404 * 'contact_type' => $contactType;
1406 * 'rule_group_id' => $ruleGroupID;
1407 * 'excludedContactIDs' => $excludedContactIDs;
1408 * @param array $dedupeResults
1409 * Array of results ['handled' => TRUE/FALSE, 'ids' => array of IDs of duplicate contacts]
1410 * @param array $contextParams
1411 * The context if relevant, eg. ['event_id' => X]
1415 public static function findDuplicates($dedupeParams, &$dedupeResults, $contextParams) {
1416 return self
::singleton()
1417 ->invoke(['dedupeParams', 'dedupeResults', 'contextParams'], $dedupeParams, $dedupeResults, $contextParams, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_findDuplicates');
1421 * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php
1423 * @param string $type
1424 * Type of mail processed: 'activity' OR 'mailing'.
1425 * @param array &$params the params that were sent to the CiviCRM API function
1426 * @param object $mail
1427 * The mail object which is an ezcMail class.
1428 * @param array &$result the result returned by the api call
1429 * @param string $action
1430 * (optional ) the requested action to be performed if the types was 'mailing'.
1434 public static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) {
1435 return self
::singleton()
1436 ->invoke(['type', 'params', 'mail', 'result', 'action'], $type, $params, $mail, $result, $action, self
::$_nullObject, 'civicrm_emailProcessor');
1440 * This hook is called after a row has been processed and the
1441 * record (and associated records imported
1443 * @param string $object
1444 * Object being imported (for now Contact only, later Contribution, Activity,.
1445 * Participant and Member)
1446 * @param string $usage
1447 * Hook usage/location (for now process only, later mapping and others).
1448 * @param string $objectRef
1449 * Import record object.
1450 * @param array $params
1451 * Array with various key values: currently.
1452 * contactID - contact id
1453 * importID - row id in temp table
1454 * importTempTable - name of tempTable
1455 * fieldHeaders - field headers
1456 * fields - import fields
1460 public static function import($object, $usage, &$objectRef, &$params) {
1461 return self
::singleton()->invoke(['object', 'usage', 'objectRef', 'params'], $object, $usage, $objectRef, $params,
1462 self
::$_nullObject, self
::$_nullObject,
1468 * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission()
1469 * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php).
1471 * @param string $entity
1472 * The API entity (like contact).
1473 * @param string $action
1474 * The API action (like get).
1475 * @param array &$params the API parameters
1476 * @param array &$permissions the associative permissions array (probably to be altered by this hook)
1480 public static function alterAPIPermissions($entity, $action, &$params, &$permissions) {
1481 return self
::singleton()->invoke(['entity', 'action', 'params', 'permissions'], $entity, $action, $params, $permissions,
1482 self
::$_nullObject, self
::$_nullObject,
1483 'civicrm_alterAPIPermissions'
1488 * @param CRM_Core_DAO $dao
1492 public static function postSave(&$dao) {
1493 $hookName = 'civicrm_postSave_' . $dao->getTableName();
1494 return self
::singleton()->invoke(['dao'], $dao,
1495 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1501 * This hook allows user to customize context menu Actions on contact summary page.
1503 * @param array $actions
1504 * Array of all Actions in contextmenu.
1505 * @param int $contactID
1506 * ContactID for the summary page.
1510 public static function summaryActions(&$actions, $contactID = NULL) {
1511 return self
::singleton()->invoke(['actions', 'contactID'], $actions, $contactID,
1512 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1513 'civicrm_summaryActions'
1518 * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go.
1519 * This enables us hook implementors to modify both the headers and the rows
1521 * The BIGGEST drawback with this hook is that you may need to modify the result template to include your
1522 * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl
1524 * However, if you use the same number of columns, you can overwrite the existing columns with the values that
1525 * you want displayed. This is a hackish, but avoids template modification.
1527 * @param string $objectName
1528 * The component name that we are doing the search.
1529 * activity, campaign, case, contact, contribution, event, grant, membership, and pledge
1530 * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order )
1531 * @param array &$rows the list of values, an associate array with fields that are displayed for that component
1532 * @param array $selector
1533 * the selector object. Allows you access to the context of the search
1536 * modify the header and values object to pass the data you need
1538 public static function searchColumns($objectName, &$headers, &$rows, &$selector) {
1539 return self
::singleton()->invoke(['objectName', 'headers', 'rows', 'selector'], $objectName, $headers, $rows, $selector,
1540 self
::$_nullObject, self
::$_nullObject,
1541 'civicrm_searchColumns'
1546 * This hook is called when uf groups are being built for a module.
1548 * @param string $moduleName
1550 * @param array $ufGroups
1551 * Array of ufgroups for a module.
1555 public static function buildUFGroupsForModule($moduleName, &$ufGroups) {
1556 return self
::singleton()->invoke(['moduleName', 'ufGroups'], $moduleName, $ufGroups,
1557 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1558 'civicrm_buildUFGroupsForModule'
1563 * This hook is called when we are determining the contactID for a specific
1566 * @param string $email
1567 * The email address.
1568 * @param int $contactID
1569 * The contactID that matches this email address, IF it exists.
1570 * @param array $result
1571 * (reference) has two fields.
1572 * contactID - the new (or same) contactID
1573 * action - 3 possible values:
1574 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record
1575 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID
1576 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address
1580 public static function emailProcessorContact($email, $contactID, &$result) {
1581 return self
::singleton()->invoke(['email', 'contactID', 'result'], $email, $contactID, $result,
1582 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1583 'civicrm_emailProcessorContact'
1588 * Hook definition for altering the generation of Mailing Labels.
1590 * @param array $args
1591 * An array of the args in the order defined for the tcpdf multiCell api call.
1592 * with the variable names below converted into string keys (ie $w become 'w'
1593 * as the first key for $args)
1594 * float $w Width of cells. If 0, they extend up to the right margin of the page.
1595 * float $h Cell minimum height. The cell extends automatically if needed.
1596 * string $txt String to print
1597 * mixed $border Indicates if borders must be drawn around the cell block. The value can
1598 * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or
1599 * a string containing some or all of the following characters (in any order):
1600 * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
1601 * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string:
1602 * left align</li><li>C: center</li><li>R: right align</li><li>J: justification
1603 * (default value when $ishtml=false)</li></ul>
1604 * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
1605 * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0:
1606 * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul>
1607 * float $x x position in user units
1608 * float $y y position in user units
1609 * boolean $reseth if true reset the last cell height (default true).
1610 * int $stretch stretch character mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if
1611 * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if
1612 * necessary</li><li>4 = forced character spacing</li></ul>
1613 * boolean $ishtml set to true if $txt is HTML content (default = false).
1614 * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width.
1615 * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page,
1616 * or 0 for disable this feature. This feature works only when $ishtml=false.
1620 public static function alterMailingLabelParams(&$args) {
1621 return self
::singleton()->invoke(['args'], $args,
1622 self
::$_nullObject, self
::$_nullObject,
1623 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1624 'civicrm_alterMailingLabelParams'
1629 * This hooks allows alteration of generated page content.
1632 * Previously generated content.
1634 * Context of content - page or form.
1636 * The file name of the tpl.
1638 * A reference to the page or form object.
1642 public static function alterContent(&$content, $context, $tplName, &$object) {
1643 return self
::singleton()->invoke(['content', 'context', 'tplName', 'object'], $content, $context, $tplName, $object,
1644 self
::$_nullObject, self
::$_nullObject,
1645 'civicrm_alterContent'
1650 * This hooks allows alteration of the tpl file used to generate content. It differs from the
1651 * altercontent hook as the content has already been rendered through the tpl at that point
1654 * Previously generated content.
1656 * Reference to the form object.
1658 * Context of content - page or form.
1660 * Reference the file name of the tpl.
1664 public static function alterTemplateFile($formName, &$form, $context, &$tplName) {
1665 return self
::singleton()->invoke(['formName', 'form', 'context', 'tplName'], $formName, $form, $context, $tplName,
1666 self
::$_nullObject, self
::$_nullObject,
1667 'civicrm_alterTemplateFile'
1672 * This hook collects the trigger definition from all components.
1675 * @param string $tableName
1676 * (optional) the name of the table that we are interested in only.
1678 * @internal param \reference $triggerInfo to an array of trigger information
1679 * each element has 4 fields:
1680 * table - array of tableName
1681 * when - BEFORE or AFTER
1682 * event - array of eventName - INSERT OR UPDATE OR DELETE
1683 * sql - array of statements optionally terminated with a ;
1684 * a statement can use the tokes {tableName} and {eventName}
1685 * to do token replacement with the table / event. This allows
1686 * templatizing logging and other hooks
1689 public static function triggerInfo(&$info, $tableName = NULL) {
1690 return self
::singleton()->invoke(['info', 'tableName'], $info, $tableName,
1691 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1693 'civicrm_triggerInfo'
1698 * This hook allows changes to the spec of which tables to log.
1700 * @param array $logTableSpec
1704 public static function alterLogTables(&$logTableSpec) {
1705 return self
::singleton()->invoke(['logTableSpec'], $logTableSpec, $_nullObject,
1706 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1708 'civicrm_alterLogTables'
1713 * This hook is called when a module-extension is installed.
1714 * Each module will receive hook_civicrm_install during its own installation (but not during the
1715 * installation of unrelated modules).
1717 public static function install() {
1718 return self
::singleton()->invoke(0, self
::$_nullObject,
1719 self
::$_nullObject, self
::$_nullObject,
1720 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1726 * This hook is called when a module-extension is uninstalled.
1727 * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the
1728 * uninstallation of unrelated modules).
1730 public static function uninstall() {
1731 return self
::singleton()->invoke(0, self
::$_nullObject,
1732 self
::$_nullObject, self
::$_nullObject,
1733 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1739 * This hook is called when a module-extension is re-enabled.
1740 * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the
1741 * re-enablement of unrelated modules).
1743 public static function enable() {
1744 return self
::singleton()->invoke(0, self
::$_nullObject,
1745 self
::$_nullObject, self
::$_nullObject,
1746 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1752 * This hook is called when a module-extension is disabled.
1753 * Each module will receive hook_civicrm_disable during its own disablement (but not during the
1754 * disablement of unrelated modules).
1756 public static function disable() {
1757 return self
::singleton()->invoke(0, self
::$_nullObject,
1758 self
::$_nullObject, self
::$_nullObject,
1759 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1767 * This hook is called when the browser is being re-directed and allows the url
1770 * @param \Psr\Http\Message\UriInterface $url
1771 * @param array $context
1772 * Additional information about context
1773 * - output - if this is 'json' then it will return json.
1776 * the return value is ignored
1778 public static function alterRedirect(&$url, &$context) {
1779 return self
::singleton()->invoke(['url', 'context'], $url,
1780 $context, self
::$_nullObject,
1781 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1782 'civicrm_alterRedirect'
1793 public static function alterReportVar($varType, &$var, &$object) {
1794 return self
::singleton()->invoke(['varType', 'var', 'object'], $varType, $var, $object,
1796 self
::$_nullObject, self
::$_nullObject,
1797 'civicrm_alterReportVar'
1802 * This hook is called to drive database upgrades for extension-modules.
1805 * The type of operation being performed; 'check' or 'enqueue'.
1806 * @param CRM_Queue_Queue $queue
1807 * (for 'enqueue') the modifiable list of pending up upgrade tasks.
1810 * NULL, if $op is 'enqueue'.
1811 * TRUE, if $op is 'check' and upgrades are pending.
1812 * FALSE, if $op is 'check' and upgrades are not pending.
1814 public static function upgrade($op, CRM_Queue_Queue
$queue = NULL) {
1815 return self
::singleton()->invoke(['op', 'queue'], $op, $queue,
1816 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1823 * This hook is called when an email has been successfully sent by CiviCRM, but not on an error.
1825 * @param array $params
1826 * The mailing parameters. Array fields include: groupName, from, toName,
1827 * toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers,
1828 * attachments (array)
1832 public static function postEmailSend(&$params) {
1833 return self
::singleton()->invoke(['params'], $params,
1834 self
::$_nullObject, self
::$_nullObject,
1835 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1836 'civicrm_postEmailSend'
1841 * This hook is called when a CiviMail mailing has completed
1843 * @param int $mailingId
1848 public static function postMailing($mailingId) {
1849 return self
::singleton()->invoke(['mailingId'], $mailingId,
1850 self
::$_nullObject, self
::$_nullObject,
1851 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1852 'civicrm_postMailing'
1857 * This hook is called when Settings specifications are loaded.
1859 * @param array $settingsFolders
1860 * List of paths from which to derive metadata
1864 public static function alterSettingsFolders(&$settingsFolders) {
1865 return self
::singleton()->invoke(['settingsFolders'], $settingsFolders,
1866 self
::$_nullObject, self
::$_nullObject,
1867 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1868 'civicrm_alterSettingsFolders'
1873 * This hook is called when Settings have been loaded from the xml
1874 * It is an opportunity for hooks to alter the data
1876 * @param array $settingsMetaData
1877 * Settings Metadata.
1878 * @param int $domainID
1879 * @param mixed $profile
1883 public static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) {
1884 return self
::singleton()->invoke(['settingsMetaData', 'domainID', 'profile'], $settingsMetaData,
1885 $domainID, $profile,
1886 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1887 'civicrm_alterSettingsMetaData'
1892 * This hook is called before running an api call.
1894 * @param API_Wrapper[] $wrappers
1895 * (see CRM_Utils_API_ReloadOption as an example)
1896 * @param mixed $apiRequest
1899 * The return value is ignored
1901 public static function apiWrappers(&$wrappers, $apiRequest) {
1902 return self
::singleton()
1903 ->invoke(['wrappers', 'apiRequest'], $wrappers, $apiRequest, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1904 self
::$_nullObject, 'civicrm_apiWrappers'
1909 * This hook is called before running pending cron jobs.
1911 * @param CRM_Core_JobManager $jobManager
1914 * The return value is ignored.
1916 public static function cron($jobManager) {
1917 return self
::singleton()->invoke(['jobManager'],
1918 $jobManager, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1924 * This hook is called when loading CMS permissions; use this hook to modify
1925 * the array of system permissions for CiviCRM.
1927 * @param array $permissions
1928 * Array of permissions. See CRM_Core_Permission::getCorePermissions() for
1929 * the format of this array.
1932 * The return value is ignored
1934 public static function permission(&$permissions) {
1935 return self
::singleton()->invoke(['permissions'], $permissions,
1936 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1937 'civicrm_permission'
1942 * This hook is called when checking permissions; use this hook to dynamically
1943 * escalate user permissions in certain use cases (cf. CRM-19256).
1945 * @param string $permission
1946 * The name of an atomic permission, ie. 'access deleted contacts'
1947 * @param bool $granted
1948 * Whether this permission is currently granted. The hook can change this value.
1949 * @param int $contactId
1950 * Contact whose permissions we are checking (if null, assume current user).
1953 * The return value is ignored
1955 public static function permission_check($permission, &$granted, $contactId) {
1956 return self
::singleton()->invoke(['permission', 'granted', 'contactId'], $permission, $granted, $contactId,
1957 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1958 'civicrm_permission_check'
1963 * @param CRM_Core_Exception $exception
1964 * @param mixed $request
1965 * Reserved for future use.
1967 public static function unhandledException($exception, $request = NULL) {
1968 $event = new \Civi\Core\Event\
UnhandledExceptionEvent($exception, self
::$_nullObject);
1969 \Civi
::dispatcher()->dispatch('hook_civicrm_unhandled_exception', $event);
1973 * This hook is called for declaring managed entities via API.
1975 * Note: This is a pre-boot hook. It will dispatch via the extension/module
1976 * subsystem but *not* the Symfony EventDispatcher.
1978 * @param array[] $entityTypes
1979 * List of entity types; each entity-type is an array with keys:
1980 * - name: string, a unique short name (e.g. "ReportInstance")
1981 * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance")
1982 * - table: string, a SQL table name (e.g. "civicrm_report_instance")
1983 * - fields_callback: array, list of callables which manipulates field list
1984 * - links_callback: array, list of callables which manipulates fk list
1987 * The return value is ignored
1989 public static function entityTypes(&$entityTypes) {
1990 return self
::singleton()->invoke(['entityTypes'], $entityTypes, self
::$_nullObject, self
::$_nullObject,
1991 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_entityTypes'
1996 * Build a description of available hooks.
1998 * @param \Civi\Core\CiviEventInspector $inspector
2000 public static function eventDefs($inspector) {
2001 $event = \Civi\Core\Event\GenericHookEvent
::create([
2002 'inspector' => $inspector,
2004 Civi
::dispatcher()->dispatch('hook_civicrm_eventDefs', $event);
2008 * This hook is called while preparing a profile form.
2010 * @param string $profileName
2013 public static function buildProfile($profileName) {
2014 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2015 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildProfile');
2019 * This hook is called while validating a profile form submission.
2021 * @param string $profileName
2024 public static function validateProfile($profileName) {
2025 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2026 self
::$_nullObject, self
::$_nullObject, 'civicrm_validateProfile');
2030 * This hook is called processing a valid profile form submission.
2032 * @param string $profileName
2035 public static function processProfile($profileName) {
2036 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2037 self
::$_nullObject, self
::$_nullObject, 'civicrm_processProfile');
2041 * This hook is called while preparing a read-only profile screen
2043 * @param string $profileName
2046 public static function viewProfile($profileName) {
2047 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2048 self
::$_nullObject, self
::$_nullObject, 'civicrm_viewProfile');
2052 * This hook is called while preparing a list of contacts (based on a profile)
2054 * @param string $profileName
2057 public static function searchProfile($profileName) {
2058 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2059 self
::$_nullObject, self
::$_nullObject, 'civicrm_searchProfile');
2063 * This hook is invoked when building a CiviCRM name badge.
2065 * @param string $labelName
2066 * String referencing name of badge format.
2067 * @param object $label
2068 * Reference to the label object.
2069 * @param array $format
2070 * Array of format data.
2071 * @param array $participant
2072 * Array of participant values.
2075 * the return value is ignored
2077 public static function alterBadge($labelName, &$label, &$format, &$participant) {
2078 return self
::singleton()
2079 ->invoke(['labelName', 'label', 'format', 'participant'], $labelName, $label, $format, $participant, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBadge');
2083 * This hook is called before encoding data in barcode.
2085 * @param array $data
2086 * Associated array of values available for encoding.
2087 * @param string $type
2088 * Type of barcode, classic barcode or QRcode.
2089 * @param string $context
2090 * Where this hooks is invoked.
2094 public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') {
2095 return self
::singleton()->invoke(['data', 'type', 'context'], $data, $type, $context, self
::$_nullObject,
2096 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBarcode');
2100 * Modify or replace the Mailer object used for outgoing mail.
2102 * @param object $mailer
2103 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
2104 * @param string $driver
2105 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
2106 * @param array $params
2107 * The default mailer config options
2110 * @see Mail::factory
2112 public static function alterMailer(&$mailer, $driver, $params) {
2113 return self
::singleton()
2114 ->invoke(['mailer', 'driver', 'params'], $mailer, $driver, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterMailer');
2118 * Deprecated: Misnamed version of alterMailer(). Remove post-4.7.x.
2119 * Modify or replace the Mailer object used for outgoing mail.
2121 * @param object $mailer
2122 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
2123 * @param string $driver
2124 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
2125 * @param array $params
2126 * The default mailer config options
2129 * @see Mail::factory
2132 public static function alterMail(&$mailer, $driver, $params) {
2133 // This has been deprecated on the premise it MIGHT be called externally for a long time.
2134 // We don't have a clear policy on how much we support external extensions calling internal
2135 // hooks (ie. in general we say 'don't call internal functions', but some hooks like pre hooks
2136 // are expected to be called externally.
2137 // It's really really unlikely anyone uses this - but let's add deprecations for a couple
2138 // of releases first.
2139 CRM_Core_Error
::deprecatedFunctionWarning('CRM_Utils_Hook::alterMailer');
2140 return CRM_Utils_Hook
::alterMailer($mailer, $driver, $params);
2144 * This hook is called while building the core search query,
2145 * so hook implementers can provide their own query objects which alters/extends core search.
2147 * @param array $queryObjects
2148 * @param string $type
2152 public static function queryObjects(&$queryObjects, $type = 'Contact') {
2153 return self
::singleton()
2154 ->invoke(['queryObjects', 'type'], $queryObjects, $type, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_queryObjects');
2158 * This hook is called while viewing contact dashboard.
2160 * @param array $availableDashlets
2161 * List of dashlets; each is formatted per api/v3/Dashboard
2162 * @param array $defaultDashlets
2163 * List of dashlets; each is formatted per api/v3/DashboardContact
2167 public static function dashboard_defaults($availableDashlets, &$defaultDashlets) {
2168 return self
::singleton()
2169 ->invoke(['availableDashlets', 'defaultDashlets'], $availableDashlets, $defaultDashlets, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_dashboard_defaults');
2173 * This hook is called before a case merge (or a case reassign)
2175 * @param int $mainContactId
2176 * @param int $mainCaseId
2177 * @param int $otherContactId
2178 * @param int $otherCaseId
2179 * @param bool $changeClient
2183 public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
2184 return self
::singleton()
2185 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_pre_case_merge');
2189 * This hook is called after a case merge (or a case reassign)
2191 * @param int $mainContactId
2192 * @param int $mainCaseId
2193 * @param int $otherContactId
2194 * @param int $otherCaseId
2195 * @param bool $changeClient
2199 public static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
2200 return self
::singleton()
2201 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_post_case_merge');
2206 * Add a hook for altering the display name
2208 * hook_civicrm_contact_get_displayname(&$display_name, $objContact)
2210 * @param string $displayName
2211 * @param int $contactId
2212 * @param object $dao
2213 * The contact object.
2217 public static function alterDisplayName(&$displayName, $contactId, $dao) {
2218 return self
::singleton()->invoke(['displayName', 'contactId', 'dao'],
2219 $displayName, $contactId, $dao, self
::$_nullObject, self
::$_nullObject,
2220 self
::$_nullObject, 'civicrm_contact_get_displayname'
2225 * Modify the CRM_Core_Resources settings data.
2227 * @param array $data
2228 * @see CRM_Core_Resources::addSetting
2230 public static function alterResourceSettings(&$data) {
2231 $event = \Civi\Core\Event\GenericHookEvent
::create([
2234 Civi
::dispatcher()->dispatch('hook_civicrm_alterResourceSettings', $event);
2238 * EXPERIMENTAL: This hook allows one to register additional Angular modules
2240 * @param array $angularModules
2241 * List of modules. Each module defines:
2242 * - ext: string, the CiviCRM extension which hosts the files.
2243 * - js: array, list of JS files or globs.
2244 * - css: array, list of CSS files or globs.
2245 * - partials: array, list of base-dirs containing HTML.
2246 * - partialsCallback: mixed, a callback function which generates a list of HTML
2247 * function(string $moduleName, array $moduleDefn) => array(string $file => string $html)
2248 * For future-proofing, use a serializable callback (e.g. string/array).
2249 * See also: Civi\Core\Resolver.
2250 * - requires: array, list of required Angular modules.
2251 * - basePages: array, uncondtionally load this module onto the given Angular pages. [v4.7.21+]
2252 * If omitted, default to "array('civicrm/a')" for backward compat.
2253 * For a utility that should only be loaded on-demand, use "array()".
2254 * For a utility that should be loaded in all pages use, "array('*')".
2256 * the return value is ignored
2259 * function mymod_civicrm_angularModules(&$angularModules) {
2260 * $angularModules['myAngularModule'] = array(
2261 * 'ext' => 'org.example.mymod',
2262 * 'js' => array('js/myAngularModule.js'),
2264 * $angularModules['myBigAngularModule'] = array(
2265 * 'ext' => 'org.example.mymod',
2266 * 'js' => array('js/part1.js', 'js/part2.js', 'ext://other.ext.name/file.js', 'assetBuilder://dynamicAsset.js'),
2267 * 'css' => array('css/myAngularModule.css', 'ext://other.ext.name/file.css', 'assetBuilder://dynamicAsset.css'),
2268 * 'partials' => array('partials/myBigAngularModule'),
2269 * 'requires' => array('otherModuleA', 'otherModuleB'),
2270 * 'basePages' => array('civicrm/a'),
2275 public static function angularModules(&$angularModules) {
2276 return self
::singleton()->invoke(['angularModules'], $angularModules,
2277 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2278 'civicrm_angularModules'
2283 * Alter the definition of some Angular HTML partials.
2285 * @param \Civi\Angular\Manager $angular
2288 * function example_civicrm_alterAngular($angular) {
2289 * $changeSet = \Civi\Angular\ChangeSet::create('mychanges')
2290 * ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(phpQueryObject $doc) {
2291 * $doc->find('[ng-form="crmMailingSubform"]')->attr('cat-stevens', 'ts(\'wild world\')');
2294 * $angular->add($changeSet);
2298 public static function alterAngular($angular) {
2299 $event = \Civi\Core\Event\GenericHookEvent
::create([
2300 'angular' => $angular,
2302 Civi
::dispatcher()->dispatch('hook_civicrm_alterAngular', $event);
2306 * This hook is called when building a link to a semi-static asset.
2308 * @param string $asset
2309 * The name of the asset.
2310 * Ex: 'angular.json'
2311 * @param array $params
2312 * List of optional arguments which influence the content.
2314 * the return value is ignored
2316 public static function getAssetUrl(&$asset, &$params) {
2317 return self
::singleton()->invoke(['asset', 'params'],
2318 $asset, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2319 'civicrm_getAssetUrl'
2324 * This hook is called whenever the system builds a new copy of
2325 * semi-static asset.
2327 * @param string $asset
2328 * The name of the asset.
2329 * Ex: 'angular.json'
2330 * @param array $params
2331 * List of optional arguments which influence the content.
2332 * Note: Params are immutable because they are part of the cache-key.
2333 * @param string $mimeType
2334 * Initially, NULL. Modify to specify the mime-type.
2335 * @param string $content
2336 * Initially, NULL. Modify to specify the rendered content.
2338 * the return value is ignored
2340 public static function buildAsset($asset, $params, &$mimeType, &$content) {
2341 return self
::singleton()->invoke(['asset', 'params', 'mimeType', 'content'],
2342 $asset, $params, $mimeType, $content, self
::$_nullObject, self
::$_nullObject,
2343 'civicrm_buildAsset'
2348 * This hook fires whenever a record in a case changes.
2350 * @param \Civi\CCase\Analyzer $analyzer
2351 * A bundle of data about the case (such as the case and activity records).
2353 public static function caseChange(\Civi\CCase\Analyzer
$analyzer) {
2354 $event = new \Civi\CCase\Event\
CaseChangeEvent($analyzer);
2355 \Civi
::dispatcher()->dispatch('hook_civicrm_caseChange', $event);
2359 * Generate a default CRUD URL for an entity.
2361 * @param array $spec
2363 * - action: int, eg CRM_Core_Action::VIEW or CRM_Core_Action::UPDATE
2364 * - entity_table: string
2366 * @param CRM_Core_DAO $bao
2367 * @param array $link
2368 * To define the link, add these keys to $link:.
2372 * - url: string (used in lieu of "path"/"query")
2373 * Note: if making "url" CRM_Utils_System::url(), set $htmlize=false
2376 public static function crudLink($spec, $bao, &$link) {
2377 return self
::singleton()->invoke(['spec', 'bao', 'link'], $spec, $bao, $link,
2378 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2384 * Modify the CiviCRM container - add new services, parameters, extensions, etc.
2387 * use Symfony\Component\Config\Resource\FileResource;
2388 * use Symfony\Component\DependencyInjection\Definition;
2390 * function mymodule_civicrm_container($container) {
2391 * $container->addResource(new FileResource(__FILE__));
2392 * $container->setDefinition('mysvc', new Definition('My\Class', array()));
2396 * Tip: The container configuration will be compiled/cached. The default cache
2397 * behavior is aggressive. When you first implement the hook, be sure to
2398 * flush the cache. Additionally, you should relax caching during development.
2399 * In `civicrm.settings.php`, set define('CIVICRM_CONTAINER_CACHE', 'auto').
2401 * Note: This is a preboot hook. It will dispatch via the extension/module
2402 * subsystem but *not* the Symfony EventDispatcher.
2404 * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
2405 * @see http://symfony.com/doc/current/components/dependency_injection/index.html
2407 public static function container(\Symfony\Component\DependencyInjection\ContainerBuilder
$container) {
2408 self
::singleton()->invoke(['container'], $container, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_container');
2412 * @param array $fileSearches CRM_Core_FileSearchInterface
2415 public static function fileSearches(&$fileSearches) {
2416 return self
::singleton()->invoke(['fileSearches'], $fileSearches,
2417 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2418 'civicrm_fileSearches'
2423 * Check system status.
2425 * @param array $messages
2426 * Array<CRM_Utils_Check_Message>. A list of messages regarding system status.
2429 public static function check(&$messages) {
2430 return self
::singleton()
2431 ->invoke(['messages'], $messages, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_check');
2435 * This hook is called when a query string of the CSV Batch export is generated.
2437 * @param string $query
2441 public static function batchQuery(&$query) {
2442 return self
::singleton()->invoke(['query'], $query, self
::$_nullObject,
2443 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2444 'civicrm_batchQuery'
2449 * This hook is called to alter Deferred revenue item values just before they are
2450 * inserted in civicrm_financial_trxn table
2452 * @param array $deferredRevenues
2454 * @param array $contributionDetails
2456 * @param bool $update
2458 * @param string $context
2462 public static function alterDeferredRevenueItems(&$deferredRevenues, $contributionDetails, $update, $context) {
2463 return self
::singleton()->invoke(['deferredRevenues', 'contributionDetails', 'update', 'context'], $deferredRevenues, $contributionDetails, $update, $context,
2464 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterDeferredRevenueItems'
2469 * This hook is called when the entries of the CSV Batch export are mapped.
2471 * @param array $results
2472 * @param array $items
2476 public static function batchItems(&$results, &$items) {
2477 return self
::singleton()->invoke(['results', 'items'], $results, $items,
2478 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2479 'civicrm_batchItems'
2484 * This hook is called when core resources are being loaded
2486 * @see CRM_Core_Resources::coreResourceList
2488 * @param array $list
2489 * @param string $region
2491 public static function coreResourceList(&$list, $region) {
2492 self
::singleton()->invoke(['list', 'region'], $list, $region,
2493 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2494 'civicrm_coreResourceList'
2499 * Allows the list of filters on the EntityRef widget to be altered.
2501 * @see CRM_Core_Resources::entityRefFilters
2503 * @param array $filters
2504 * @param array $links
2506 public static function entityRefFilters(&$filters, &$links = NULL) {
2507 self
::singleton()->invoke(['filters', 'links'], $filters, $links, self
::$_nullObject,
2508 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2509 'civicrm_entityRefFilters'
2514 * This hook is called for bypass a few civicrm urls from IDS check.
2516 * @param array $skip list of civicrm urls
2520 public static function idsException(&$skip) {
2521 return self
::singleton()->invoke(['skip'], $skip, self
::$_nullObject,
2522 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2523 'civicrm_idsException'
2528 * This hook is called when a geocoder's format method is called.
2530 * @param string $geoProvider
2531 * @param array $values
2532 * @param SimpleXMLElement $xml
2536 public static function geocoderFormat($geoProvider, &$values, $xml) {
2537 return self
::singleton()->invoke(['geoProvider', 'values', 'xml'], $geoProvider, $values, $xml,
2538 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2539 'civicrm_geocoderFormat'
2544 * This hook is called before an inbound SMS is processed.
2546 * @param \CRM_SMS_Message $message
2547 * An SMS message received
2550 public static function inboundSMS(&$message) {
2551 return self
::singleton()->invoke(['message'], $message, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_inboundSMS');
2555 * This hook is called to modify api params of EntityRef form field
2557 * @param array $params
2558 * @param string $formName
2561 public static function alterEntityRefParams(&$params, $formName) {
2562 return self
::singleton()->invoke(['params', 'formName'], $params, $formName,
2563 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2564 'civicrm_alterEntityRefParams'
2569 * This hook is called before a scheduled job is executed
2571 * @param CRM_Core_DAO_Job $job
2572 * The job to be executed
2573 * @param array $params
2574 * The arguments to be given to the job
2576 public static function preJob($job, $params) {
2577 return self
::singleton()->invoke(['job', 'params'], $job, $params,
2578 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2584 * This hook is called after a scheduled job is executed
2586 * @param CRM_Core_DAO_Job $job
2587 * The job that was executed
2588 * @param array $params
2589 * The arguments given to the job
2590 * @param array $result
2591 * The result of the API call, or the thrown exception if any
2593 public static function postJob($job, $params, $result) {
2594 return self
::singleton()->invoke(['job', 'params', 'result'], $job, $params, $result,
2595 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2601 * This hook is called before and after constructing mail recipients.
2602 * Allows user to alter filter and/or search query to fetch mail recipients
2604 * @param CRM_Mailing_DAO_Mailing $mailingObject
2605 * @param array $criteria
2606 * A list of SQL criteria; you can add/remove/replace/modify criteria.
2607 * Array(string $name => CRM_Utils_SQL_Select $criterion).
2608 * Ex: array('do_not_email' => CRM_Utils_SQL_Select::fragment()->where("$contact.do_not_email = 0")).
2609 * @param string $context
2613 public static function alterMailingRecipients(&$mailingObject, &$criteria, $context) {
2614 return self
::singleton()->invoke(['mailingObject', 'params', 'context'],
2615 $mailingObject, $criteria, $context,
2616 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2617 'civicrm_alterMailingRecipients'
2622 * ALlow Extensions to custom process IPN hook data such as sending Google Analyitcs information based on the IPN
2623 * @param array $IPNData - Array of IPN Data
2626 public static function postIPNProcess(&$IPNData) {
2627 return self
::singleton()->invoke(['IPNData'],
2628 $IPNData, self
::$_nullObject, self
::$_nullObject,
2629 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2630 'civicrm_postIPNProcess'