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 if (!is_array($names)) {
156 // We were called with the old contract wherein $names is actually an int.
157 // Symfony dispatcher requires some kind of name.
158 // TODO: Emit a warning, eg
159 // error_log("Warning: hook_$fnSuffix does not give names for its parameters. It will present odd names to any Symfony event listeners.");
160 $compatNames = ['arg1', 'arg2', 'arg3', 'arg4', 'arg5', 'arg6'];
161 $names = array_slice($compatNames, 0, (int) $names);
164 $event = \Civi\Core\Event\GenericHookEvent
::createOrdered(
166 array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6)
168 \Civi
::dispatcher()->dispatch('hook_' . $fnSuffix, $event);
169 return $event->getReturnValues();
173 * @param array $numParams
185 public function commonInvoke(
187 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
191 $this->commonBuildModuleList($fnPrefix);
193 return $this->runHooks($this->commonCiviModules
, $fnSuffix,
194 $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6
199 * Build the list of modules to be processed for hooks.
201 * @param string $fnPrefix
203 public function commonBuildModuleList($fnPrefix) {
204 if (!$this->commonIncluded
) {
205 // include external file
206 $this->commonIncluded
= TRUE;
208 $config = CRM_Core_Config
::singleton();
209 if (!empty($config->customPHPPathDir
)) {
210 $civicrmHooksFile = CRM_Utils_File
::addTrailingSlash($config->customPHPPathDir
) . 'civicrmHooks.php';
211 if (file_exists($civicrmHooksFile)) {
212 @include_once
$civicrmHooksFile;
216 if (!empty($fnPrefix)) {
217 $this->commonCiviModules
[$fnPrefix] = $fnPrefix;
220 $this->requireCiviModules($this->commonCiviModules
);
227 * @param array $civiModules
228 * @param string $fnSuffix
229 * @param int $numParams
238 * @throws \CRM_Core_Exception
240 public function runHooks(
241 $civiModules, $fnSuffix, $numParams,
242 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6
244 // $civiModules is *not* passed by reference because runHooks
245 // must be reentrant. PHP is finicky about running
246 // multiple loops over the same variable. The circumstances
247 // to reproduce the issue are pretty intricate.
250 $fnNames = $this->cache
->get($fnSuffix);
251 if (!is_array($fnNames)) {
253 if ($civiModules !== NULL) {
254 foreach ($civiModules as $module) {
255 $fnName = "{$module}_{$fnSuffix}";
256 if (function_exists($fnName)) {
257 $fnNames[] = $fnName;
260 $this->cache
->set($fnSuffix, $fnNames);
264 foreach ($fnNames as $fnName) {
266 switch ($numParams) {
268 $fResult = $fnName();
272 $fResult = $fnName($arg1);
276 $fResult = $fnName($arg1, $arg2);
280 $fResult = $fnName($arg1, $arg2, $arg3);
284 $fResult = $fnName($arg1, $arg2, $arg3, $arg4);
288 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5);
292 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
296 throw new CRM_Core_Exception(ts('Invalid hook invocation'));
299 if (!empty($fResult) &&
302 $result = array_merge($result, $fResult);
306 return empty($result) ?
TRUE : $result;
312 public function requireCiviModules(&$moduleList) {
313 $civiModules = CRM_Core_PseudoConstant
::getModuleExtensions();
314 foreach ($civiModules as $civiModule) {
315 if (!file_exists($civiModule['filePath'])) {
316 CRM_Core_Session
::setStatus(
317 ts('Error loading module file (%1). Please restore the file or disable the module.',
318 [1 => $civiModule['filePath']]),
319 ts('Warning'), 'error');
322 include_once $civiModule['filePath'];
323 $moduleList[$civiModule['prefix']] = $civiModule['prefix'];
328 * This hook is called before a db write on some core objects.
329 * This hook does not allow the abort of the operation
332 * The type of operation being performed.
333 * @param string $objectName
334 * The name of the object.
336 * The object id if available.
337 * @param array $params
338 * The parameters used for object creation / editing.
341 * the return value is ignored
343 public static function pre($op, $objectName, $id, &$params) {
344 $event = new \Civi\Core\Event\
PreEvent($op, $objectName, $id, $params);
345 \Civi
::dispatcher()->dispatch('hook_civicrm_pre', $event);
346 return $event->getReturnValues();
350 * This hook is called after a db write on some core objects.
353 * The type of operation being performed.
354 * @param string $objectName
355 * The name of the object.
356 * @param int $objectId
357 * The unique identifier for the object.
358 * @param object $objectRef
359 * The reference to the object if available.
362 * based on op. pre-hooks return a boolean or
363 * an error message which aborts the operation
365 public static function post($op, $objectName, $objectId, &$objectRef = NULL) {
366 $event = new \Civi\Core\Event\
PostEvent($op, $objectName, $objectId, $objectRef);
367 \Civi
::dispatcher()->dispatch('hook_civicrm_post', $event);
368 return $event->getReturnValues();
372 * This hook is equivalent to post(), except that it is guaranteed to run
373 * outside of any SQL transaction. The objectRef is not modifiable.
375 * This hook is defined for two cases:
377 * 1. If the original action runs within a transaction, then the hook fires
378 * after the transaction commits.
379 * 2. If the original action runs outside a transaction, then the data was
380 * committed immediately, and we can run the hook immediately.
383 * The type of operation being performed.
384 * @param string $objectName
385 * The name of the object.
386 * @param int $objectId
387 * The unique identifier for the object.
388 * @param object $objectRef
389 * The reference to the object if available.
392 * based on op. pre-hooks return a boolean or
393 * an error message which aborts the operation
395 public static function postCommit($op, $objectName, $objectId, $objectRef = NULL) {
396 $event = new \Civi\Core\Event\
PostEvent($op, $objectName, $objectId, $objectRef);
397 \Civi
::dispatcher()->dispatch('hook_civicrm_postCommit', $event);
398 return $event->getReturnValues();
402 * This hook retrieves links from other modules and injects it into.
403 * the view contact tabs
406 * The type of operation being performed.
407 * @param string $objectName
408 * The name of the object.
409 * @param int $objectId
410 * The unique identifier for the object.
411 * @param array $links
412 * (optional) the links array (introduced in v3.2).
414 * (optional) the bitmask to show/hide links.
415 * @param array $values
416 * (optional) the values to fill the links.
419 * the return value is ignored
421 public static function links($op, $objectName, &$objectId, &$links, &$mask = NULL, &$values = []) {
422 return self
::singleton()->invoke(['op', 'objectName', 'objectId', 'links', 'mask', 'values'], $op, $objectName, $objectId, $links, $mask, $values, 'civicrm_links');
426 * This hook is invoked during the CiviCRM form preProcess phase.
428 * @param string $formName
429 * The name of the form.
430 * @param CRM_Core_Form $form
431 * Reference to the form object.
434 * the return value is ignored
436 public static function preProcess($formName, &$form) {
437 return self
::singleton()
438 ->invoke(['formName', 'form'], $formName, $form, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_preProcess');
442 * This hook is invoked when building a CiviCRM form. This hook should also
443 * be used to set the default values of a form element
445 * @param string $formName
446 * The name of the form.
447 * @param CRM_Core_Form $form
448 * Reference to the form object.
451 * the return value is ignored
453 public static function buildForm($formName, &$form) {
454 return self
::singleton()->invoke(['formName', 'form'], $formName, $form,
455 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
461 * This hook is invoked when a CiviCRM form is submitted. If the module has injected
462 * any form elements, this hook should save the values in the database
464 * @param string $formName
465 * The name of the form.
466 * @param CRM_Core_Form $form
467 * Reference to the form object.
470 * the return value is ignored
472 public static function postProcess($formName, &$form) {
473 return self
::singleton()->invoke(['formName', 'form'], $formName, $form,
474 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
475 'civicrm_postProcess'
480 * This hook is invoked during all CiviCRM form validation. An array of errors
481 * detected is returned. Else we assume validation succeeded.
483 * @param string $formName
484 * The name of the form.
485 * @param array &$fields the POST parameters as filtered by QF
486 * @param array &$files the FILES parameters as sent in by POST
487 * @param array &$form the form object
488 * @param array &$errors the array of errors.
491 * formRule hooks return a boolean or
492 * an array of error messages which display a QF Error
494 public static function validateForm($formName, &$fields, &$files, &$form, &$errors) {
495 return self
::singleton()
496 ->invoke(['formName', 'fields', 'files', 'form', 'errors'],
497 $formName, $fields, $files, $form, $errors, self
::$_nullObject, 'civicrm_validateForm');
501 * This hook is called after a db write on a custom table.
504 * The type of operation being performed.
505 * @param string $groupID
506 * The custom group ID.
507 * @param object $entityID
508 * The entityID of the row in the custom table.
509 * @param array $params
510 * The parameters that were sent into the calling function.
513 * the return value is ignored
515 public static function custom($op, $groupID, $entityID, &$params) {
516 return self
::singleton()
517 ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_custom');
521 * This hook is called before a db write on a custom table.
524 * The type of operation being performed.
525 * @param string $groupID
526 * The custom group ID.
527 * @param object $entityID
528 * The entityID of the row in the custom table.
529 * @param array $params
530 * The parameters that were sent into the calling function.
533 * the return value is ignored
535 public static function customPre($op, $groupID, $entityID, &$params) {
536 return self
::singleton()
537 ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self
::$_nullObject, self
::$_nullObject, 'civicrm_customPre');
541 * This hook is called when composing the ACL where clause to restrict
542 * visibility of contacts to the logged in user
545 * The type of permission needed.
546 * @param array $tables
547 * (reference ) add the tables that are needed for the select clause.
548 * @param array $whereTables
549 * (reference ) add the tables that are needed for the where clause.
550 * @param int $contactID
551 * The contactID for whom the check is made.
552 * @param string $where
553 * The currrent where clause.
556 * the return value is ignored
558 public static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) {
559 return self
::singleton()
560 ->invoke(['type', 'tables', 'whereTables', 'contactID', 'where'], $type, $tables, $whereTables, $contactID, $where, self
::$_nullObject, 'civicrm_aclWhereClause');
564 * This hook is called when composing the ACL where clause to restrict
565 * visibility of contacts to the logged in user
568 * The type of permission needed.
569 * @param int $contactID
570 * The contactID for whom the check is made.
571 * @param string $tableName
572 * The tableName which is being permissioned.
573 * @param array $allGroups
574 * The set of all the objects for the above table.
575 * @param array $currentGroups
576 * The set of objects that are currently permissioned for this contact.
579 * the return value is ignored
581 public static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) {
582 return self
::singleton()
583 ->invoke(['type', 'contactID', 'tableName', 'allGroups', 'currentGroups'], $type, $contactID, $tableName, $allGroups, $currentGroups, self
::$_nullObject, 'civicrm_aclGroup');
587 * @param string|CRM_Core_DAO $entity
588 * @param array $clauses
591 public static function selectWhereClause($entity, &$clauses) {
592 $entityName = is_object($entity) ?
_civicrm_api_get_entity_name_from_dao($entity) : $entity;
593 return self
::singleton()->invoke(['entity', 'clauses'], $entityName, $clauses,
594 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
595 'civicrm_selectWhereClause'
600 * This hook is called when building the menu table.
602 * @param array $files
603 * The current set of files to process.
606 * the return value is ignored
608 public static function xmlMenu(&$files) {
609 return self
::singleton()->invoke(['files'], $files,
610 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
616 * (Experimental) This hook is called when build the menu table.
618 * @param array $items
619 * List of records to include in menu table.
621 * the return value is ignored
623 public static function alterMenu(&$items) {
624 return self
::singleton()->invoke(['items'], $items,
625 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
631 * A theme is a set of CSS files which are loaded on CiviCRM pages. To register a new
632 * theme, add it to the $themes array. Use these properties:
634 * - ext: string (required)
635 * The full name of the extension which defines the theme.
636 * Ex: "org.civicrm.themes.greenwich".
637 * - title: string (required)
639 * - help: string (optional)
640 * Description of the theme's appearance.
641 * - url_callback: mixed (optional)
642 * A function ($themes, $themeKey, $cssExt, $cssFile) which returns the URL(s) for a CSS resource.
643 * Returns either an array of URLs or PASSTHRU.
644 * Ex: \Civi\Core\Themes\Resolvers::simple (default)
645 * Ex: \Civi\Core\Themes\Resolvers::none
646 * - prefix: string (optional)
647 * A prefix within the extension folder to prepend to the file name.
648 * - search_order: array (optional)
649 * A list of themes to search.
650 * Generally, the last theme should be "*fallback*" (Civi\Core\Themes::FALLBACK).
651 * - excludes: array (optional)
652 * A list of files (eg "civicrm:css/bootstrap.css" or "$ext:$file") which should never
653 * be returned (they are excluded from display).
655 * @param array $themes
656 * List of themes, keyed by name.
658 * the return value is ignored
660 public static function themes(&$themes) {
661 return self
::singleton()->invoke(['themes'], $themes,
662 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
668 * The activeTheme hook determines which theme is active.
670 * @param string $theme
671 * The identifier for the theme. Alterable.
673 * @param array $context
674 * Information about the current page-request. Includes some mix of:
675 * - page: the relative path of the current Civi page (Ex: 'civicrm/dashboard').
676 * - themes: an instance of the Civi\Core\Themes service.
678 * the return value is ignored
680 public static function activeTheme(&$theme, $context) {
681 return self
::singleton()->invoke(array('theme', 'context'), $theme, $context,
682 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
683 'civicrm_activeTheme'
688 * This hook is called for declaring managed entities via API.
690 * @param array $entities
691 * List of pending entities. Each entity is an array with keys:
692 * + '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")
693 * + 'name': string, a symbolic name which can be used to track this entity (Note: Each module creates its own namespace)
694 * + 'entity': string, an entity-type supported by the CiviCRM API (Note: this currently must be an entity which supports the 'is_active' property)
695 * + 'params': array, the entity data as supported by the CiviCRM API
696 * + 'update' (v4.5+): string, a policy which describes when to update records
697 * - 'always' (default): always update the managed-entity record; changes in $entities will override any local changes (eg by the site-admin)
698 * - 'never': never update the managed-entity record; changes made locally (eg by the site-admin) will override changes in $entities
699 * + '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)
700 * - 'always' (default): always delete orphaned records
701 * - 'never': never delete orphaned records
702 * - '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.)
705 * the return value is ignored
707 public static function managed(&$entities) {
708 return self
::singleton()->invoke(['entities'], $entities,
709 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
715 * This hook is called when rendering the dashboard (q=civicrm/dashboard)
717 * @param int $contactID
718 * The contactID for whom the dashboard is being rendered.
719 * @param int $contentPlacement
720 * (output parameter) where should the hook content be displayed.
721 * relative to the activity list
724 * the html snippet to include in the dashboard
726 public static function dashboard($contactID, &$contentPlacement = self
::DASHBOARD_BELOW
) {
727 $retval = self
::singleton()->invoke(['contactID', 'contentPlacement'], $contactID, $contentPlacement,
728 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
733 * Note we need this seemingly unnecessary code because in the event that the implementation
734 * of the hook declares the second parameter but doesn't set it, then it comes back unset even
735 * though we have a default value in this function's declaration above.
737 if (!isset($contentPlacement)) {
738 $contentPlacement = self
::DASHBOARD_BELOW
;
745 * This hook is called before storing recently viewed items.
747 * @param array $recentArray
748 * An array of recently viewed or processed items, for in place modification.
752 public static function recent(&$recentArray) {
753 return self
::singleton()->invoke(['recentArray'], $recentArray,
754 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
760 * Determine how many other records refer to a given record.
762 * @param CRM_Core_DAO $dao
763 * The item for which we want a reference count.
764 * @param array $refCounts
765 * Each item in the array is an Array with keys:
766 * - name: string, eg "sql:civicrm_email:contact_id"
767 * - type: string, eg "sql"
768 * - count: int, eg "5" if there are 5 email addresses that refer to $dao
771 * Return is not really intended to be used.
773 public static function referenceCounts($dao, &$refCounts) {
774 return self
::singleton()->invoke(['dao', 'refCounts'], $dao, $refCounts,
775 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
776 'civicrm_referenceCounts'
781 * This hook is called when building the amount structure for a Contribution or Event Page.
783 * @param int $pageType
784 * Is this a contribution or event page.
785 * @param CRM_Core_Form $form
786 * Reference to the form object.
787 * @param array $amount
788 * The amount structure to be displayed.
792 public static function buildAmount($pageType, &$form, &$amount) {
793 return self
::singleton()->invoke(['pageType', 'form', 'amount'], $pageType, $form, $amount, self
::$_nullObject,
794 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildAmount');
798 * This hook is called when building the state list for a particular country.
800 * @param array $countryID
801 * The country id whose states are being selected.
806 public static function buildStateProvinceForCountry($countryID, &$states) {
807 return self
::singleton()->invoke(['countryID', 'states'], $countryID, $states,
808 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
809 'civicrm_buildStateProvinceForCountry'
814 * This hook is called when rendering the tabs for a contact (q=civicrm/contact/view)c
817 * The array of tabs that will be displayed.
818 * @param int $contactID
819 * The contactID for whom the dashboard is being rendered.
822 * @deprecated Use tabset() instead.
824 public static function tabs(&$tabs, $contactID) {
825 return self
::singleton()->invoke(['tabs', 'contactID'], $tabs, $contactID,
826 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabs'
831 * This hook is called when rendering the tabs used for events and potentially
832 * contribution pages, etc.
834 * @param string $tabsetName
835 * Name of the screen or visual element.
837 * Tabs that will be displayed.
838 * @param array $context
839 * Extra data about the screen or context in which the tab is used.
843 public static function tabset($tabsetName, &$tabs, $context) {
844 return self
::singleton()->invoke(['tabsetName', 'tabs', 'context'], $tabsetName, $tabs,
845 $context, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tabset'
850 * This hook is called when sending an email / printing labels
852 * @param array $tokens
853 * The list of tokens that can be used for the contact.
857 public static function tokens(&$tokens) {
858 return self
::singleton()->invoke(['tokens'], $tokens,
859 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_tokens'
864 * This hook allows modification of the admin panels
866 * @param array $panels
867 * Associated array of admin panels
871 public static function alterAdminPanel(&$panels) {
872 return self
::singleton()->invoke(array('panels'), $panels,
873 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
874 'civicrm_alterAdminPanel'
879 * This hook is called when sending an email / printing labels to get the values for all the
880 * tokens returned by the 'tokens' hook
882 * @param array $details
883 * The array to store the token values indexed by contactIDs.
884 * @param array $contactIDs
885 * An array of contactIDs.
887 * The jobID if this is associated with a CiviMail mailing.
888 * @param array $tokens
889 * The list of tokens associated with the content.
890 * @param string $className
891 * The top level className from where the hook is invoked.
895 public static function tokenValues(
902 return self
::singleton()
903 ->invoke(['details', 'contactIDs', 'jobID', 'tokens', 'className'], $details, $contactIDs, $jobID, $tokens, $className, self
::$_nullObject, 'civicrm_tokenValues');
907 * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables
910 * @param object $page
911 * The page that will be rendered.
915 public static function pageRun(&$page) {
916 return self
::singleton()->invoke(['page'], $page,
917 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
923 * This hook is called after a copy of an object has been made. The current objects are
924 * Event, Contribution Page and UFGroup
926 * @param string $objectName
927 * Name of the object.
928 * @param object $object
929 * Reference to the copy.
933 public static function copy($objectName, &$object) {
934 return self
::singleton()->invoke(['objectName', 'object'], $objectName, $object,
935 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
941 * This hook is called when a contact unsubscribes from a mailing. It allows modules
942 * to override what the contacts are removed from.
946 * @param int $mailingId
947 * The id of the mailing to unsub from
948 * @param int $contactId
949 * The id of the contact who is unsubscribing
950 * @param array|int $groups
951 * Groups the contact will be removed from.
952 * @param array|int $baseGroups
953 * Base groups (used in smart mailings) the contact will be removed from.
958 public static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) {
959 return self
::singleton()
960 ->invoke(['op', 'mailingId', 'contactId', 'groups', 'baseGroups'], $op, $mailingId, $contactId, $groups, $baseGroups, self
::$_nullObject, 'civicrm_unsubscribeGroups');
964 * This hook is called when CiviCRM needs to edit/display a custom field with options
966 * @deprecated in favor of hook_civicrm_fieldOptions
968 * @param int $customFieldID
969 * The custom field ID.
970 * @param array $options
971 * The current set of options for that custom field.
972 * You can add/remove existing options.
973 * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important
974 * to be careful to not overwrite the array.
975 * Only add/edit/remove the specific field options you intend to affect.
976 * @param bool $detailedFormat
977 * If true, the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format
978 * @param array $selectAttributes
979 * Contain select attribute(s) if any.
983 public static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE, $selectAttributes = []) {
984 // Weird: $selectAttributes is inputted but not outputted.
985 return self
::singleton()->invoke(['customFieldID', 'options', 'detailedFormat'], $customFieldID, $options, $detailedFormat,
986 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
987 'civicrm_customFieldOptions'
992 * Hook for modifying field options
994 * @param string $entity
995 * @param string $field
996 * @param array $options
997 * @param array $params
1001 public static function fieldOptions($entity, $field, &$options, $params) {
1002 return self
::singleton()->invoke(['entity', 'field', 'options', 'params'], $entity, $field, $options, $params,
1003 self
::$_nullObject, self
::$_nullObject,
1004 'civicrm_fieldOptions'
1010 * This hook is called to display the list of actions allowed after doing a search.
1011 * This allows the module developer to inject additional actions or to remove existing actions.
1013 * @param string $objectType
1014 * The object type for this search.
1015 * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported.
1016 * @param array $tasks
1017 * The current set of tasks for that custom field.
1018 * You can add/remove existing tasks.
1019 * Each task needs to have a title (eg 'title' => ts( 'Group - add contacts')) and a class
1020 * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
1021 * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
1022 * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be
1023 * found in CRM/$objectType/Task.php.
1027 public static function searchTasks($objectType, &$tasks) {
1028 return self
::singleton()->invoke(['objectType', 'tasks'], $objectType, $tasks,
1029 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1030 'civicrm_searchTasks'
1035 * @param mixed $form
1036 * @param array $params
1040 public static function eventDiscount(&$form, &$params) {
1041 return self
::singleton()->invoke(['form', 'params'], $form, $params,
1042 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1043 'civicrm_eventDiscount'
1048 * This hook is called when composing a mailing. You can include / exclude other groups as needed.
1050 * @param mixed $form
1051 * The form object for which groups / mailings being displayed
1052 * @param array $groups
1053 * The list of groups being included / excluded
1054 * @param array $mailings
1055 * The list of mailings being included / excluded
1059 public static function mailingGroups(&$form, &$groups, &$mailings) {
1060 return self
::singleton()->invoke(['form', 'groups', 'mailings'], $form, $groups, $mailings,
1061 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1062 'civicrm_mailingGroups'
1067 * (Experimental) Modify the list of template-types used for CiviMail composition.
1069 * @param array $types
1070 * Sequentially indexed list of template types. Each type specifies:
1072 * - editorUrl: string, Angular template URL
1073 * - weight: int, priority when picking a default value for new mailings
1076 public static function mailingTemplateTypes(&$types) {
1077 return self
::singleton()->invoke(['types'], $types, self
::$_nullObject, self
::$_nullObject,
1078 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1079 'civicrm_mailingTemplateTypes'
1084 * This hook is called when composing the array of membershipTypes and their cost during a membership registration
1086 * Note the hook is called on initial page load and also reloaded after submit (PRG pattern).
1087 * You can use it to alter the membership types when first loaded, or after submission
1088 * (for example if you want to gather data in the form and use it to alter the fees).
1090 * @param mixed $form
1091 * The form object that is presenting the page
1092 * @param array $membershipTypes
1093 * The array of membership types and their amount
1097 public static function membershipTypeValues(&$form, &$membershipTypes) {
1098 return self
::singleton()->invoke(['form', 'membershipTypes'], $form, $membershipTypes,
1099 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1100 'civicrm_membershipTypeValues'
1105 * This hook is called when rendering the contact summary.
1107 * @param int $contactID
1108 * The contactID for whom the summary is being rendered
1109 * @param mixed $content
1110 * @param int $contentPlacement
1111 * Specifies where the hook content should be displayed relative to the
1115 * The html snippet to include in the contact summary
1117 public static function summary($contactID, &$content, &$contentPlacement = self
::SUMMARY_BELOW
) {
1118 return self
::singleton()->invoke(['contactID', 'content', 'contentPlacement'], $contactID, $content, $contentPlacement,
1119 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1125 * Use this hook to populate the list of contacts returned by Contact Reference custom fields.
1126 * By default, Contact Reference fields will search on and return all CiviCRM contacts.
1127 * If you want to limit the contacts returned to a specific group, or some other criteria
1128 * - you can override that behavior by providing a SQL query that returns some subset of your contacts.
1129 * The hook is called when the query is executed to get the list of contacts to display.
1131 * @param mixed $query
1132 * - the query that will be executed (input and output parameter);.
1133 * It's important to realize that the ACL clause is built prior to this hook being fired,
1134 * so your query will ignore any ACL rules that may be defined.
1135 * Your query must return two columns:
1136 * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data')
1138 * @param string $queryText
1139 * The name string to execute the query against (this is the value being typed in by the user).
1140 * @param string $context
1141 * The context in which this ajax call is being made (for example: 'customfield', 'caseview').
1143 * The id of the object for which the call is being made.
1144 * For custom fields, it will be the custom field id
1148 public static function contactListQuery(&$query, $queryText, $context, $id) {
1149 return self
::singleton()->invoke(['query', 'queryText', 'context', 'id'], $query, $queryText, $context, $id,
1150 self
::$_nullObject, self
::$_nullObject,
1151 'civicrm_contactListQuery'
1156 * Hook definition for altering payment parameters before talking to a payment processor back end.
1158 * Definition will look like this:
1160 * function hook_civicrm_alterPaymentProcessorParams(
1166 * @param CRM_Core_Payment $paymentObj
1167 * Instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy')
1168 * See discussion in CRM-16224 as to whether $paymentObj should be passed by reference.
1169 * @param array &$rawParams
1170 * array of params as passed to to the processor
1171 * @param array|\Civi\Payment\PropertyBag &$cookedParams
1172 * params after the processor code has translated them into its own key/value pairs
1175 * This return is not really intended to be used.
1177 public static function alterPaymentProcessorParams(
1182 return self
::singleton()->invoke(['paymentObj', 'rawParams', 'cookedParams'], $paymentObj, $rawParams, $cookedParams,
1183 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1184 'civicrm_alterPaymentProcessorParams'
1189 * This hook is called when an email is about to be sent by CiviCRM.
1191 * @param array $params
1192 * Array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html,
1193 * returnPath, replyTo, headers, attachments (array)
1194 * @param string $context
1195 * The context in which the hook is being invoked, eg 'civimail'.
1199 public static function alterMailParams(&$params, $context = NULL) {
1200 return self
::singleton()->invoke(['params', 'context'], $params, $context,
1201 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1202 'civicrm_alterMailParams'
1207 * This hook is called when membership status is being calculated.
1209 * @param array $membershipStatus
1210 * Membership status details as determined - alter if required.
1211 * @param array $arguments
1212 * Arguments passed in to calculate date.
1217 * - 'exclude_is_admin'
1218 * - 'membership_type_id'
1219 * @param array $membership
1220 * Membership details from the calling function.
1224 public static function alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) {
1225 return self
::singleton()->invoke(['membershipStatus', 'arguments', 'membership'], $membershipStatus, $arguments,
1226 $membership, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1227 'civicrm_alterCalculatedMembershipStatus'
1232 * This hook is called after getting the content of the mail and before tokenizing it.
1234 * @param array $content
1235 * Array fields include: html, text, subject
1239 public static function alterMailContent(&$content) {
1240 return self
::singleton()->invoke(['content'], $content,
1241 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1242 'civicrm_alterMailContent'
1247 * This hook is called when rendering the Manage Case screen.
1249 * @param int $caseID
1253 * Array of data to be displayed, where the key is a unique id to be used for styling (div id's)
1254 * and the value is an array with keys 'label' and 'value' specifying label/value pairs
1256 public static function caseSummary($caseID) {
1257 return self
::singleton()->invoke(['caseID'], $caseID,
1258 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1259 'civicrm_caseSummary'
1264 * This hook is called when locating CiviCase types.
1266 * @param array $caseTypes
1270 public static function caseTypes(&$caseTypes) {
1271 return self
::singleton()
1272 ->invoke(['caseTypes'], $caseTypes, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_caseTypes');
1276 * This hook is called soon after the CRM_Core_Config object has ben initialized.
1277 * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically.
1279 * @param CRM_Core_Config|array $config
1284 public static function config(&$config) {
1285 return self
::singleton()->invoke(['config'], $config,
1286 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1292 * This hooks allows to change option values.
1294 * @deprecated in favor of hook_civicrm_fieldOptions
1296 * @param array $options
1297 * Associated array of option values / id
1298 * @param string $groupName
1303 public static function optionValues(&$options, $groupName) {
1304 return self
::singleton()->invoke(['options', 'groupName'], $options, $groupName,
1305 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1306 'civicrm_optionValues'
1311 * This hook allows modification of the navigation menu.
1313 * @param array $params
1314 * Associated array of navigation menu entry to Modify/Add
1318 public static function navigationMenu(&$params) {
1319 return self
::singleton()->invoke(['params'], $params,
1320 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1321 'civicrm_navigationMenu'
1326 * This hook allows modification of the data used to perform merging of duplicates.
1328 * @param string $type
1329 * The type of data being passed (cidRefs|eidRefs|relTables|sqls).
1330 * @param array $data
1331 * The data, as described in $type.
1332 * @param int $mainId
1333 * Contact_id of the contact that survives the merge.
1334 * @param int $otherId
1335 * Contact_id of the contact that will be absorbed and deleted.
1336 * @param array $tables
1337 * When $type is "sqls", an array of tables as it may have been handed to the calling function.
1341 public static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) {
1342 return self
::singleton()->invoke(['type', 'data', 'mainId', 'otherId', 'tables'], $type, $data, $mainId, $otherId, $tables, self
::$_nullObject, 'civicrm_merge');
1346 * This hook allows modification of the data calculated for merging locations.
1348 * @param array $blocksDAO
1349 * Array of location DAO to be saved. These are arrays in 2 keys 'update' & 'delete'.
1350 * @param int $mainId
1351 * Contact_id of the contact that survives the merge.
1352 * @param int $otherId
1353 * Contact_id of the contact that will be absorbed and deleted.
1354 * @param array $migrationInfo
1355 * Calculated migration info, informational only.
1359 public static function alterLocationMergeData(&$blocksDAO, $mainId, $otherId, $migrationInfo) {
1360 return self
::singleton()->invoke(['blocksDAO', 'mainId', 'otherId', 'migrationInfo'], $blocksDAO, $mainId, $otherId, $migrationInfo, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterLocationMergeData');
1364 * This hook provides a way to override the default privacy behavior for notes.
1366 * @param array &$noteValues
1367 * Associative array of values for this note
1371 public static function notePrivacy(&$noteValues) {
1372 return self
::singleton()->invoke(['noteValues'], $noteValues,
1373 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1374 'civicrm_notePrivacy'
1379 * This hook is called before record is exported as CSV.
1381 * @param string $exportTempTable
1382 * Name of the temporary export table used during export.
1383 * @param array $headerRows
1384 * Header rows for output.
1385 * @param array $sqlColumns
1387 * @param int $exportMode
1388 * Export mode ( contact, contribution, etc...).
1389 * @param string $componentTable
1390 * Name of temporary table
1392 * Array of object's ids
1396 public static function export(&$exportTempTable, &$headerRows, &$sqlColumns, $exportMode, $componentTable, $ids) {
1397 return self
::singleton()->invoke(['exportTempTable', 'headerRows', 'sqlColumns', 'exportMode', 'componentTable', 'ids'],
1398 $exportTempTable, $headerRows, $sqlColumns,
1399 $exportMode, $componentTable, $ids,
1405 * This hook allows modification of the queries constructed from dupe rules.
1407 * @param string $obj
1408 * Object of rulegroup class.
1409 * @param string $type
1410 * Type of queries e.g table / threshold.
1411 * @param array $query
1416 public static function dupeQuery($obj, $type, &$query) {
1417 return self
::singleton()->invoke(['obj', 'type', 'query'], $obj, $type, $query,
1418 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1424 * Check for duplicate contacts
1426 * @param array $dedupeParams
1427 * Array of params for finding duplicates: [
1428 * '{parameters returned by CRM_Dedupe_Finder::formatParams}
1429 * 'check_permission' => TRUE/FALSE;
1430 * 'contact_type' => $contactType;
1432 * 'rule_group_id' => $ruleGroupID;
1433 * 'excludedContactIDs' => $excludedContactIDs;
1434 * @param array $dedupeResults
1435 * Array of results ['handled' => TRUE/FALSE, 'ids' => array of IDs of duplicate contacts]
1436 * @param array $contextParams
1437 * The context if relevant, eg. ['event_id' => X]
1441 public static function findDuplicates($dedupeParams, &$dedupeResults, $contextParams) {
1442 return self
::singleton()
1443 ->invoke(['dedupeParams', 'dedupeResults', 'contextParams'], $dedupeParams, $dedupeResults, $contextParams, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_findDuplicates');
1447 * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php
1449 * @param string $type
1450 * Type of mail processed: 'activity' OR 'mailing'.
1451 * @param array &$params the params that were sent to the CiviCRM API function
1452 * @param object $mail
1453 * The mail object which is an ezcMail class.
1454 * @param array &$result the result returned by the api call
1455 * @param string $action
1456 * (optional ) the requested action to be performed if the types was 'mailing'.
1460 public static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) {
1461 return self
::singleton()
1462 ->invoke(['type', 'params', 'mail', 'result', 'action'], $type, $params, $mail, $result, $action, self
::$_nullObject, 'civicrm_emailProcessor');
1466 * This hook is called after a row has been processed and the
1467 * record (and associated records imported
1469 * @param string $object
1470 * Object being imported (for now Contact only, later Contribution, Activity,.
1471 * Participant and Member)
1472 * @param string $usage
1473 * Hook usage/location (for now process only, later mapping and others).
1474 * @param string $objectRef
1475 * Import record object.
1476 * @param array $params
1477 * Array with various key values: currently.
1478 * contactID - contact id
1479 * importID - row id in temp table
1480 * importTempTable - name of tempTable
1481 * fieldHeaders - field headers
1482 * fields - import fields
1486 public static function import($object, $usage, &$objectRef, &$params) {
1487 return self
::singleton()->invoke(['object', 'usage', 'objectRef', 'params'], $object, $usage, $objectRef, $params,
1488 self
::$_nullObject, self
::$_nullObject,
1494 * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission()
1495 * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php).
1497 * @param string $entity
1498 * The API entity (like contact).
1499 * @param string $action
1500 * The API action (like get).
1501 * @param array &$params the API parameters
1502 * @param array &$permissions the associative permissions array (probably to be altered by this hook)
1506 public static function alterAPIPermissions($entity, $action, &$params, &$permissions) {
1507 return self
::singleton()->invoke(['entity', 'action', 'params', 'permissions'], $entity, $action, $params, $permissions,
1508 self
::$_nullObject, self
::$_nullObject,
1509 'civicrm_alterAPIPermissions'
1514 * @param CRM_Core_DAO $dao
1518 public static function postSave(&$dao) {
1519 $hookName = 'civicrm_postSave_' . $dao->getTableName();
1520 return self
::singleton()->invoke(['dao'], $dao,
1521 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1527 * This hook allows user to customize context menu Actions on contact summary page.
1529 * @param array $actions
1530 * Array of all Actions in contextmenu.
1531 * @param int $contactID
1532 * ContactID for the summary page.
1536 public static function summaryActions(&$actions, $contactID = NULL) {
1537 return self
::singleton()->invoke(['actions', 'contactID'], $actions, $contactID,
1538 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1539 'civicrm_summaryActions'
1544 * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go.
1545 * This enables us hook implementors to modify both the headers and the rows
1547 * The BIGGEST drawback with this hook is that you may need to modify the result template to include your
1548 * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl
1550 * However, if you use the same number of columns, you can overwrite the existing columns with the values that
1551 * you want displayed. This is a hackish, but avoids template modification.
1553 * @param string $objectName
1554 * The component name that we are doing the search.
1555 * activity, campaign, case, contact, contribution, event, grant, membership, and pledge
1556 * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order )
1557 * @param array &$rows the list of values, an associate array with fields that are displayed for that component
1558 * @param array $selector
1559 * the selector object. Allows you access to the context of the search
1562 * modify the header and values object to pass the data you need
1564 public static function searchColumns($objectName, &$headers, &$rows, &$selector) {
1565 return self
::singleton()->invoke(['objectName', 'headers', 'rows', 'selector'], $objectName, $headers, $rows, $selector,
1566 self
::$_nullObject, self
::$_nullObject,
1567 'civicrm_searchColumns'
1572 * This hook is called when uf groups are being built for a module.
1574 * @param string $moduleName
1576 * @param array $ufGroups
1577 * Array of ufgroups for a module.
1581 public static function buildUFGroupsForModule($moduleName, &$ufGroups) {
1582 return self
::singleton()->invoke(['moduleName', 'ufGroups'], $moduleName, $ufGroups,
1583 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1584 'civicrm_buildUFGroupsForModule'
1589 * This hook is called when we are determining the contactID for a specific
1592 * @param string $email
1593 * The email address.
1594 * @param int $contactID
1595 * The contactID that matches this email address, IF it exists.
1596 * @param array $result
1597 * (reference) has two fields.
1598 * contactID - the new (or same) contactID
1599 * action - 3 possible values:
1600 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record
1601 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID
1602 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address
1606 public static function emailProcessorContact($email, $contactID, &$result) {
1607 return self
::singleton()->invoke(['email', 'contactID', 'result'], $email, $contactID, $result,
1608 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1609 'civicrm_emailProcessorContact'
1614 * Hook definition for altering the generation of Mailing Labels.
1616 * @param array $args
1617 * An array of the args in the order defined for the tcpdf multiCell api call.
1618 * with the variable names below converted into string keys (ie $w become 'w'
1619 * as the first key for $args)
1620 * float $w Width of cells. If 0, they extend up to the right margin of the page.
1621 * float $h Cell minimum height. The cell extends automatically if needed.
1622 * string $txt String to print
1623 * mixed $border Indicates if borders must be drawn around the cell block. The value can
1624 * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or
1625 * a string containing some or all of the following characters (in any order):
1626 * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
1627 * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string:
1628 * left align</li><li>C: center</li><li>R: right align</li><li>J: justification
1629 * (default value when $ishtml=false)</li></ul>
1630 * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
1631 * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0:
1632 * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul>
1633 * float $x x position in user units
1634 * float $y y position in user units
1635 * boolean $reseth if true reset the last cell height (default true).
1636 * int $stretch stretch character mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if
1637 * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if
1638 * necessary</li><li>4 = forced character spacing</li></ul>
1639 * boolean $ishtml set to true if $txt is HTML content (default = false).
1640 * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width.
1641 * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page,
1642 * or 0 for disable this feature. This feature works only when $ishtml=false.
1646 public static function alterMailingLabelParams(&$args) {
1647 return self
::singleton()->invoke(['args'], $args,
1648 self
::$_nullObject, self
::$_nullObject,
1649 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1650 'civicrm_alterMailingLabelParams'
1655 * This hooks allows alteration of generated page content.
1658 * Previously generated content.
1660 * Context of content - page or form.
1662 * The file name of the tpl.
1664 * A reference to the page or form object.
1668 public static function alterContent(&$content, $context, $tplName, &$object) {
1669 return self
::singleton()->invoke(['content', 'context', 'tplName', 'object'], $content, $context, $tplName, $object,
1670 self
::$_nullObject, self
::$_nullObject,
1671 'civicrm_alterContent'
1676 * This hooks allows alteration of the tpl file used to generate content. It differs from the
1677 * altercontent hook as the content has already been rendered through the tpl at that point
1680 * Previously generated content.
1682 * Reference to the form object.
1684 * Context of content - page or form.
1686 * Reference the file name of the tpl.
1690 public static function alterTemplateFile($formName, &$form, $context, &$tplName) {
1691 return self
::singleton()->invoke(['formName', 'form', 'context', 'tplName'], $formName, $form, $context, $tplName,
1692 self
::$_nullObject, self
::$_nullObject,
1693 'civicrm_alterTemplateFile'
1698 * This hook collects the trigger definition from all components.
1701 * @param string $tableName
1702 * (optional) the name of the table that we are interested in only.
1704 * @internal param \reference $triggerInfo to an array of trigger information
1705 * each element has 4 fields:
1706 * table - array of tableName
1707 * when - BEFORE or AFTER
1708 * event - array of eventName - INSERT OR UPDATE OR DELETE
1709 * sql - array of statements optionally terminated with a ;
1710 * a statement can use the tokes {tableName} and {eventName}
1711 * to do token replacement with the table / event. This allows
1712 * templatizing logging and other hooks
1715 public static function triggerInfo(&$info, $tableName = NULL) {
1716 return self
::singleton()->invoke(['info', 'tableName'], $info, $tableName,
1717 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1719 'civicrm_triggerInfo'
1724 * This hook allows changes to the spec of which tables to log.
1726 * @param array $logTableSpec
1730 public static function alterLogTables(&$logTableSpec) {
1731 return self
::singleton()->invoke(['logTableSpec'], $logTableSpec, $_nullObject,
1732 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1734 'civicrm_alterLogTables'
1739 * This hook is called when a module-extension is installed.
1740 * Each module will receive hook_civicrm_install during its own installation (but not during the
1741 * installation of unrelated modules).
1743 public static function install() {
1744 // Actually invoke via CRM_Extension_Manager_Module::callHook
1745 throw new \
RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__
, __FUNCTION__
));
1749 * This hook is called when a module-extension is uninstalled.
1750 * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the
1751 * uninstallation of unrelated modules).
1753 public static function uninstall() {
1754 // Actually invoke via CRM_Extension_Manager_Module::callHook
1755 throw new \
RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__
, __FUNCTION__
));
1759 * This hook is called when a module-extension is re-enabled.
1760 * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the
1761 * re-enablement of unrelated modules).
1763 public static function enable() {
1764 // Actually invoke via CRM_Extension_Manager_Module::callHook
1765 throw new \
RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__
, __FUNCTION__
));
1769 * This hook is called when a module-extension is disabled.
1770 * Each module will receive hook_civicrm_disable during its own disablement (but not during the
1771 * disablement of unrelated modules).
1773 public static function disable() {
1774 // Actually invoke via CRM_Extension_Manager_Module::callHook
1775 throw new \
RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__
, __FUNCTION__
));
1781 * This hook is called when the browser is being re-directed and allows the url
1784 * @param \Psr\Http\Message\UriInterface $url
1785 * @param array $context
1786 * Additional information about context
1787 * - output - if this is 'json' then it will return json.
1790 * the return value is ignored
1792 public static function alterRedirect(&$url, &$context) {
1793 return self
::singleton()->invoke(['url', 'context'], $url,
1794 $context, self
::$_nullObject,
1795 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1796 'civicrm_alterRedirect'
1807 public static function alterReportVar($varType, &$var, &$object) {
1808 return self
::singleton()->invoke(['varType', 'var', 'object'], $varType, $var, $object,
1810 self
::$_nullObject, self
::$_nullObject,
1811 'civicrm_alterReportVar'
1816 * This hook is called to drive database upgrades for extension-modules.
1819 * The type of operation being performed; 'check' or 'enqueue'.
1820 * @param CRM_Queue_Queue $queue
1821 * (for 'enqueue') the modifiable list of pending up upgrade tasks.
1824 * NULL, if $op is 'enqueue'.
1825 * TRUE, if $op is 'check' and upgrades are pending.
1826 * FALSE, if $op is 'check' and upgrades are not pending.
1828 public static function upgrade($op, CRM_Queue_Queue
$queue = NULL) {
1829 return self
::singleton()->invoke(['op', 'queue'], $op, $queue,
1830 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1837 * This hook is called when an email has been successfully sent by CiviCRM, but not on an error.
1839 * @param array $params
1840 * The mailing parameters. Array fields include: groupName, from, toName,
1841 * toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers,
1842 * attachments (array)
1846 public static function postEmailSend(&$params) {
1847 return self
::singleton()->invoke(['params'], $params,
1848 self
::$_nullObject, self
::$_nullObject,
1849 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1850 'civicrm_postEmailSend'
1855 * This hook is called when a CiviMail mailing has completed
1857 * @param int $mailingId
1862 public static function postMailing($mailingId) {
1863 return self
::singleton()->invoke(['mailingId'], $mailingId,
1864 self
::$_nullObject, self
::$_nullObject,
1865 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1866 'civicrm_postMailing'
1871 * This hook is called when Settings specifications are loaded.
1873 * @param array $settingsFolders
1874 * List of paths from which to derive metadata
1878 public static function alterSettingsFolders(&$settingsFolders) {
1879 return self
::singleton()->invoke(['settingsFolders'], $settingsFolders,
1880 self
::$_nullObject, self
::$_nullObject,
1881 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1882 'civicrm_alterSettingsFolders'
1887 * This hook is called when Settings have been loaded from the xml
1888 * It is an opportunity for hooks to alter the data
1890 * @param array $settingsMetaData
1891 * Settings Metadata.
1892 * @param int $domainID
1893 * @param mixed $profile
1897 public static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) {
1898 return self
::singleton()->invoke(['settingsMetaData', 'domainID', 'profile'], $settingsMetaData,
1899 $domainID, $profile,
1900 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1901 'civicrm_alterSettingsMetaData'
1906 * This hook is called before running an api call.
1908 * @param API_Wrapper[] $wrappers
1909 * (see CRM_Utils_API_ReloadOption as an example)
1910 * @param mixed $apiRequest
1913 * The return value is ignored
1915 public static function apiWrappers(&$wrappers, $apiRequest) {
1916 return self
::singleton()
1917 ->invoke(['wrappers', 'apiRequest'], $wrappers, $apiRequest, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1918 self
::$_nullObject, 'civicrm_apiWrappers'
1923 * This hook is called before running pending cron jobs.
1925 * @param CRM_Core_JobManager $jobManager
1928 * The return value is ignored.
1930 public static function cron($jobManager) {
1931 return self
::singleton()->invoke(['jobManager'],
1932 $jobManager, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1938 * This hook is called when loading CMS permissions; use this hook to modify
1939 * the array of system permissions for CiviCRM.
1941 * @param array $permissions
1942 * Array of permissions. See CRM_Core_Permission::getCorePermissions() for
1943 * the format of this array.
1946 * The return value is ignored
1948 public static function permission(&$permissions) {
1949 return self
::singleton()->invoke(['permissions'], $permissions,
1950 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1951 'civicrm_permission'
1956 * This hook is called when checking permissions; use this hook to dynamically
1957 * escalate user permissions in certain use cases (cf. CRM-19256).
1959 * @param string $permission
1960 * The name of an atomic permission, ie. 'access deleted contacts'
1961 * @param bool $granted
1962 * Whether this permission is currently granted. The hook can change this value.
1963 * @param int $contactId
1964 * Contact whose permissions we are checking (if null, assume current user).
1967 * The return value is ignored
1969 public static function permission_check($permission, &$granted, $contactId) {
1970 return self
::singleton()->invoke(['permission', 'granted', 'contactId'], $permission, $granted, $contactId,
1971 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
1972 'civicrm_permission_check'
1977 * @param CRM_Core_Exception $exception
1978 * @param mixed $request
1979 * Reserved for future use.
1981 public static function unhandledException($exception, $request = NULL) {
1982 $event = new \Civi\Core\Event\
UnhandledExceptionEvent($exception, self
::$_nullObject);
1983 \Civi
::dispatcher()->dispatch('hook_civicrm_unhandled_exception', $event);
1987 * This hook is called for declaring managed entities via API.
1989 * Note: This is a pre-boot hook. It will dispatch via the extension/module
1990 * subsystem but *not* the Symfony EventDispatcher.
1992 * @param array[] $entityTypes
1993 * List of entity types; each entity-type is an array with keys:
1994 * - name: string, a unique short name (e.g. "ReportInstance")
1995 * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance")
1996 * - table: string, a SQL table name (e.g. "civicrm_report_instance")
1997 * - fields_callback: array, list of callables which manipulates field list
1998 * - links_callback: array, list of callables which manipulates fk list
2001 * The return value is ignored
2003 public static function entityTypes(&$entityTypes) {
2004 return self
::singleton()->invoke(['entityTypes'], $entityTypes, self
::$_nullObject, self
::$_nullObject,
2005 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_entityTypes'
2010 * Build a description of available hooks.
2012 * @param \Civi\Core\CiviEventInspector $inspector
2014 public static function eventDefs($inspector) {
2015 $event = \Civi\Core\Event\GenericHookEvent
::create([
2016 'inspector' => $inspector,
2018 Civi
::dispatcher()->dispatch('hook_civicrm_eventDefs', $event);
2022 * This hook is called while preparing a profile form.
2024 * @param string $profileName
2027 public static function buildProfile($profileName) {
2028 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2029 self
::$_nullObject, self
::$_nullObject, 'civicrm_buildProfile');
2033 * This hook is called while validating a profile form submission.
2035 * @param string $profileName
2038 public static function validateProfile($profileName) {
2039 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2040 self
::$_nullObject, self
::$_nullObject, 'civicrm_validateProfile');
2044 * This hook is called processing a valid profile form submission.
2046 * @param string $profileName
2049 public static function processProfile($profileName) {
2050 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2051 self
::$_nullObject, self
::$_nullObject, 'civicrm_processProfile');
2055 * This hook is called while preparing a read-only profile screen
2057 * @param string $profileName
2060 public static function viewProfile($profileName) {
2061 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2062 self
::$_nullObject, self
::$_nullObject, 'civicrm_viewProfile');
2066 * This hook is called while preparing a list of contacts (based on a profile)
2068 * @param string $profileName
2071 public static function searchProfile($profileName) {
2072 return self
::singleton()->invoke(['profileName'], $profileName, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2073 self
::$_nullObject, self
::$_nullObject, 'civicrm_searchProfile');
2077 * This hook is invoked when building a CiviCRM name badge.
2079 * @param string $labelName
2080 * String referencing name of badge format.
2081 * @param object $label
2082 * Reference to the label object.
2083 * @param array $format
2084 * Array of format data.
2085 * @param array $participant
2086 * Array of participant values.
2089 * the return value is ignored
2091 public static function alterBadge($labelName, &$label, &$format, &$participant) {
2092 return self
::singleton()
2093 ->invoke(['labelName', 'label', 'format', 'participant'], $labelName, $label, $format, $participant, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBadge');
2097 * This hook is called before encoding data in barcode.
2099 * @param array $data
2100 * Associated array of values available for encoding.
2101 * @param string $type
2102 * Type of barcode, classic barcode or QRcode.
2103 * @param string $context
2104 * Where this hooks is invoked.
2108 public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') {
2109 return self
::singleton()->invoke(['data', 'type', 'context'], $data, $type, $context, self
::$_nullObject,
2110 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterBarcode');
2114 * Modify or replace the Mailer object used for outgoing mail.
2116 * @param object $mailer
2117 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
2118 * @param string $driver
2119 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
2120 * @param array $params
2121 * The default mailer config options
2124 * @see Mail::factory
2126 public static function alterMailer(&$mailer, $driver, $params) {
2127 return self
::singleton()
2128 ->invoke(['mailer', 'driver', 'params'], $mailer, $driver, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_alterMailer');
2132 * This hook is called while building the core search query,
2133 * so hook implementers can provide their own query objects which alters/extends core search.
2135 * @param array $queryObjects
2136 * @param string $type
2140 public static function queryObjects(&$queryObjects, $type = 'Contact') {
2141 return self
::singleton()
2142 ->invoke(['queryObjects', 'type'], $queryObjects, $type, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_queryObjects');
2146 * This hook is called while viewing contact dashboard.
2148 * @param array $availableDashlets
2149 * List of dashlets; each is formatted per api/v3/Dashboard
2150 * @param array $defaultDashlets
2151 * List of dashlets; each is formatted per api/v3/DashboardContact
2155 public static function dashboard_defaults($availableDashlets, &$defaultDashlets) {
2156 return self
::singleton()
2157 ->invoke(['availableDashlets', 'defaultDashlets'], $availableDashlets, $defaultDashlets, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_dashboard_defaults');
2161 * This hook is called before a case merge (or a case reassign)
2163 * @param int $mainContactId
2164 * @param int $mainCaseId
2165 * @param int $otherContactId
2166 * @param int $otherCaseId
2167 * @param bool $changeClient
2171 public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
2172 return self
::singleton()
2173 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self
::$_nullObject, 'civicrm_pre_case_merge');
2177 * This hook is called after 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 post_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_post_case_merge');
2194 * Add a hook for altering the display name
2196 * hook_civicrm_contact_get_displayname(&$display_name, $objContact)
2198 * @param string $displayName
2199 * @param int $contactId
2200 * @param object $dao
2201 * The contact object.
2205 public static function alterDisplayName(&$displayName, $contactId, $dao) {
2206 return self
::singleton()->invoke(['displayName', 'contactId', 'dao'],
2207 $displayName, $contactId, $dao, self
::$_nullObject, self
::$_nullObject,
2208 self
::$_nullObject, 'civicrm_contact_get_displayname'
2213 * Modify the CRM_Core_Resources settings data.
2215 * @param array $data
2216 * @see CRM_Core_Resources::addSetting
2218 public static function alterResourceSettings(&$data) {
2219 $event = \Civi\Core\Event\GenericHookEvent
::create([
2222 Civi
::dispatcher()->dispatch('hook_civicrm_alterResourceSettings', $event);
2226 * EXPERIMENTAL: This hook allows one to register additional Angular modules
2228 * @param array $angularModules
2229 * List of modules. Each module defines:
2230 * - ext: string, the CiviCRM extension which hosts the files.
2231 * - js: array, list of JS files or globs.
2232 * - css: array, list of CSS files or globs.
2233 * - partials: array, list of base-dirs containing HTML.
2234 * - partialsCallback: mixed, a callback function which generates a list of HTML
2235 * function(string $moduleName, array $moduleDefn) => array(string $file => string $html)
2236 * For future-proofing, use a serializable callback (e.g. string/array).
2237 * See also: Civi\Core\Resolver.
2238 * - requires: array, list of required Angular modules.
2239 * - basePages: array, uncondtionally load this module onto the given Angular pages. [v4.7.21+]
2240 * If omitted, default to "array('civicrm/a')" for backward compat.
2241 * For a utility that should only be loaded on-demand, use "array()".
2242 * For a utility that should be loaded in all pages use, "array('*')".
2245 * function mymod_civicrm_angularModules(&$angularModules) {
2246 * $angularModules['myAngularModule'] = array(
2247 * 'ext' => 'org.example.mymod',
2248 * 'js' => array('js/myAngularModule.js'),
2250 * $angularModules['myBigAngularModule'] = array(
2251 * 'ext' => 'org.example.mymod',
2252 * 'js' => array('js/part1.js', 'js/part2.js', 'ext://other.ext.name/file.js', 'assetBuilder://dynamicAsset.js'),
2253 * 'css' => array('css/myAngularModule.css', 'ext://other.ext.name/file.css', 'assetBuilder://dynamicAsset.css'),
2254 * 'partials' => array('partials/myBigAngularModule'),
2255 * 'requires' => array('otherModuleA', 'otherModuleB'),
2256 * 'basePages' => array('civicrm/a'),
2262 * the return value is ignored
2264 public static function angularModules(&$angularModules) {
2265 return self
::singleton()->invoke(['angularModules'], $angularModules,
2266 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2267 'civicrm_angularModules'
2272 * Alter the definition of some Angular HTML partials.
2274 * @param \Civi\Angular\Manager $angular
2277 * function example_civicrm_alterAngular($angular) {
2278 * $changeSet = \Civi\Angular\ChangeSet::create('mychanges')
2279 * ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(phpQueryObject $doc) {
2280 * $doc->find('[ng-form="crmMailingSubform"]')->attr('cat-stevens', 'ts(\'wild world\')');
2283 * $angular->add($changeSet);
2287 public static function alterAngular($angular) {
2288 $event = \Civi\Core\Event\GenericHookEvent
::create([
2289 'angular' => $angular,
2291 Civi
::dispatcher()->dispatch('hook_civicrm_alterAngular', $event);
2295 * This hook is called when building a link to a semi-static asset.
2297 * @param string $asset
2298 * The name of the asset.
2299 * Ex: 'angular.json'
2300 * @param array $params
2301 * List of optional arguments which influence the content.
2303 * the return value is ignored
2305 public static function getAssetUrl(&$asset, &$params) {
2306 return self
::singleton()->invoke(['asset', 'params'],
2307 $asset, $params, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2308 'civicrm_getAssetUrl'
2313 * This hook is called whenever the system builds a new copy of
2314 * semi-static asset.
2316 * @param string $asset
2317 * The name of the asset.
2318 * Ex: 'angular.json'
2319 * @param array $params
2320 * List of optional arguments which influence the content.
2321 * Note: Params are immutable because they are part of the cache-key.
2322 * @param string $mimeType
2323 * Initially, NULL. Modify to specify the mime-type.
2324 * @param string $content
2325 * Initially, NULL. Modify to specify the rendered content.
2327 * the return value is ignored
2329 public static function buildAsset($asset, $params, &$mimeType, &$content) {
2330 return self
::singleton()->invoke(['asset', 'params', 'mimeType', 'content'],
2331 $asset, $params, $mimeType, $content, self
::$_nullObject, self
::$_nullObject,
2332 'civicrm_buildAsset'
2337 * This hook fires whenever a record in a case changes.
2339 * @param \Civi\CCase\Analyzer $analyzer
2340 * A bundle of data about the case (such as the case and activity records).
2342 public static function caseChange(\Civi\CCase\Analyzer
$analyzer) {
2343 $event = new \Civi\CCase\Event\
CaseChangeEvent($analyzer);
2344 \Civi
::dispatcher()->dispatch('hook_civicrm_caseChange', $event);
2348 * Generate a default CRUD URL for an entity.
2350 * @param array $spec
2352 * - action: int, eg CRM_Core_Action::VIEW or CRM_Core_Action::UPDATE
2353 * - entity_table: string
2355 * @param CRM_Core_DAO $bao
2356 * @param array $link
2357 * To define the link, add these keys to $link:.
2361 * - url: string (used in lieu of "path"/"query")
2362 * Note: if making "url" CRM_Utils_System::url(), set $htmlize=false
2365 public static function crudLink($spec, $bao, &$link) {
2366 return self
::singleton()->invoke(['spec', 'bao', 'link'], $spec, $bao, $link,
2367 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2373 * Modify the CiviCRM container - add new services, parameters, extensions, etc.
2376 * use Symfony\Component\Config\Resource\FileResource;
2377 * use Symfony\Component\DependencyInjection\Definition;
2379 * function mymodule_civicrm_container($container) {
2380 * $container->addResource(new FileResource(__FILE__));
2381 * $container->setDefinition('mysvc', new Definition('My\Class', array()));
2385 * Tip: The container configuration will be compiled/cached. The default cache
2386 * behavior is aggressive. When you first implement the hook, be sure to
2387 * flush the cache. Additionally, you should relax caching during development.
2388 * In `civicrm.settings.php`, set define('CIVICRM_CONTAINER_CACHE', 'auto').
2390 * Note: This is a preboot hook. It will dispatch via the extension/module
2391 * subsystem but *not* the Symfony EventDispatcher.
2393 * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
2394 * @see http://symfony.com/doc/current/components/dependency_injection/index.html
2396 public static function container(\Symfony\Component\DependencyInjection\ContainerBuilder
$container) {
2397 self
::singleton()->invoke(['container'], $container, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_container');
2401 * @param array $fileSearches CRM_Core_FileSearchInterface
2404 public static function fileSearches(&$fileSearches) {
2405 return self
::singleton()->invoke(['fileSearches'], $fileSearches,
2406 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2407 'civicrm_fileSearches'
2412 * Check system status.
2414 * @param CRM_Utils_Check_Message[] $messages
2415 * A list of messages regarding system status
2416 * @param array $statusNames
2417 * If specified, only these checks are being requested and others should be skipped
2418 * @param bool $includeDisabled
2419 * Run checks that have been explicitly disabled (default false)
2422 public static function check(&$messages, $statusNames = [], $includeDisabled = FALSE) {
2423 return self
::singleton()->invoke(['messages'],
2424 $messages, $statusNames, $includeDisabled,
2425 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2431 * This hook is called when a query string of the CSV Batch export is generated.
2433 * @param string $query
2437 public static function batchQuery(&$query) {
2438 return self
::singleton()->invoke(['query'], $query, self
::$_nullObject,
2439 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2440 'civicrm_batchQuery'
2445 * This hook is called to alter Deferred revenue item values just before they are
2446 * inserted in civicrm_financial_trxn table
2448 * @param array $deferredRevenues
2450 * @param array $contributionDetails
2452 * @param bool $update
2454 * @param string $context
2458 public static function alterDeferredRevenueItems(&$deferredRevenues, $contributionDetails, $update, $context) {
2459 return self
::singleton()->invoke(['deferredRevenues', 'contributionDetails', 'update', 'context'], $deferredRevenues, $contributionDetails, $update, $context,
2460 self
::$_nullObject, self
::$_nullObject, 'civicrm_alterDeferredRevenueItems'
2465 * This hook is called when the entries of the CSV Batch export are mapped.
2467 * @param array $results
2468 * @param array $items
2472 public static function batchItems(&$results, &$items) {
2473 return self
::singleton()->invoke(['results', 'items'], $results, $items,
2474 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2475 'civicrm_batchItems'
2480 * This hook is called when core resources are being loaded
2482 * @see CRM_Core_Resources::coreResourceList
2484 * @param array $list
2485 * @param string $region
2487 public static function coreResourceList(&$list, $region) {
2488 self
::singleton()->invoke(['list', 'region'], $list, $region,
2489 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2490 'civicrm_coreResourceList'
2495 * Allows the list of filters on the EntityRef widget to be altered.
2497 * @see CRM_Core_Resources::entityRefFilters
2499 * @param array $filters
2500 * @param array $links
2502 public static function entityRefFilters(&$filters, &$links = NULL) {
2503 self
::singleton()->invoke(['filters', 'links'], $filters, $links, self
::$_nullObject,
2504 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2505 'civicrm_entityRefFilters'
2510 * This hook is called for bypass a few civicrm urls from IDS check.
2512 * @param array $skip list of civicrm urls
2516 public static function idsException(&$skip) {
2517 return self
::singleton()->invoke(['skip'], $skip, self
::$_nullObject,
2518 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2519 'civicrm_idsException'
2524 * This hook is called when a geocoder's format method is called.
2526 * @param string $geoProvider
2527 * @param array $values
2528 * @param SimpleXMLElement $xml
2532 public static function geocoderFormat($geoProvider, &$values, $xml) {
2533 return self
::singleton()->invoke(['geoProvider', 'values', 'xml'], $geoProvider, $values, $xml,
2534 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2535 'civicrm_geocoderFormat'
2540 * This hook is called before an inbound SMS is processed.
2542 * @param \CRM_SMS_Message $message
2543 * An SMS message received
2546 public static function inboundSMS(&$message) {
2547 return self
::singleton()->invoke(['message'], $message, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, 'civicrm_inboundSMS');
2551 * This hook is called to modify api params of EntityRef form field
2553 * @param array $params
2554 * @param string $formName
2557 public static function alterEntityRefParams(&$params, $formName) {
2558 return self
::singleton()->invoke(['params', 'formName'], $params, $formName,
2559 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2560 'civicrm_alterEntityRefParams'
2565 * This hook is called before a scheduled job is executed
2567 * @param CRM_Core_DAO_Job $job
2568 * The job to be executed
2569 * @param array $params
2570 * The arguments to be given to the job
2572 public static function preJob($job, $params) {
2573 return self
::singleton()->invoke(['job', 'params'], $job, $params,
2574 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2580 * This hook is called after a scheduled job is executed
2582 * @param CRM_Core_DAO_Job $job
2583 * The job that was executed
2584 * @param array $params
2585 * The arguments given to the job
2586 * @param array $result
2587 * The result of the API call, or the thrown exception if any
2589 public static function postJob($job, $params, $result) {
2590 return self
::singleton()->invoke(['job', 'params', 'result'], $job, $params, $result,
2591 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2597 * This hook is called before and after constructing mail recipients.
2598 * Allows user to alter filter and/or search query to fetch mail recipients
2600 * @param CRM_Mailing_DAO_Mailing $mailingObject
2601 * @param array $criteria
2602 * A list of SQL criteria; you can add/remove/replace/modify criteria.
2603 * Array(string $name => CRM_Utils_SQL_Select $criterion).
2604 * Ex: array('do_not_email' => CRM_Utils_SQL_Select::fragment()->where("$contact.do_not_email = 0")).
2605 * @param string $context
2609 public static function alterMailingRecipients(&$mailingObject, &$criteria, $context) {
2610 return self
::singleton()->invoke(['mailingObject', 'params', 'context'],
2611 $mailingObject, $criteria, $context,
2612 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2613 'civicrm_alterMailingRecipients'
2618 * ALlow Extensions to custom process IPN hook data such as sending Google Analyitcs information based on the IPN
2619 * @param array $IPNData - Array of IPN Data
2622 public static function postIPNProcess(&$IPNData) {
2623 return self
::singleton()->invoke(['IPNData'],
2624 $IPNData, self
::$_nullObject, self
::$_nullObject,
2625 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2626 'civicrm_postIPNProcess'
2631 * Allow extensions to modify the array of acceptable fields to be included on profiles
2632 * @param array $fields
2633 * format is [Entity => array of DAO fields]
2636 public static function alterUFFields(&$fields) {
2637 return self
::singleton()->invoke(['fields'],
2638 $fields, self
::$_nullObject, self
::$_nullObject,
2639 self
::$_nullObject, self
::$_nullObject, self
::$_nullObject,
2640 'civicrm_alterUFFields'
2645 * This hook is called to alter Custom field value before its displayed.
2647 * @param string $displayValue
2648 * @param mixed $value
2649 * @param int $entityId
2650 * @param array $fieldInfo
2654 public static function alterCustomFieldDisplayValue(&$displayValue, $value, $entityId, $fieldInfo) {
2655 return self
::singleton()->invoke(
2656 ['displayValue', 'value', 'entityId', 'fieldInfo'],
2657 $displayValue, $value, $entityId, $fieldInfo, self
::$_nullObject,
2658 self
::$_nullObject, 'civicrm_alterCustomFieldDisplayValue'