Merge pull request #24022 from colemanw/afformFrontend
[civicrm-core.git] / CRM / Utils / Hook.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CiviCRM_Hook
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035 16 */
6a488035
TO
17abstract class CRM_Utils_Hook {
18
19 // Allowed values for dashboard hook content placement
20 // Default - place content below activity list
7da04cde 21 const DASHBOARD_BELOW = 1;
6a488035 22 // Place content above activity list
7da04cde 23 const DASHBOARD_ABOVE = 2;
6a488035 24 // Don't display activity list at all
7da04cde 25 const DASHBOARD_REPLACE = 3;
6a488035
TO
26
27 // by default - place content below existing content
7da04cde 28 const SUMMARY_BELOW = 1;
50bfb460 29 // place hook content above
7da04cde 30 const SUMMARY_ABOVE = 2;
6714d8d2
SL
31 /**
32 *create your own summaries
33 */
7da04cde 34 const SUMMARY_REPLACE = 3;
6a488035 35
6714d8d2 36 /**
e97c66ff 37 * Object to pass when an object is required to be passed by params.
38 *
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.
41 *
42 * @var null
6714d8d2
SL
43 */
44 public static $_nullObject = NULL;
6a488035
TO
45
46 /**
47 * We only need one instance of this object. So we use the singleton
48 * pattern and cache the instance in this variable
49 *
e97c66ff 50 * @var CRM_Utils_Hook
6a488035
TO
51 */
52 static private $_singleton = NULL;
53
54 /**
55 * @var bool
56 */
57 private $commonIncluded = FALSE;
58
59 /**
ee3db087 60 * @var array|string
6a488035 61 */
be2fb01f 62 private $commonCiviModules = [];
6a488035 63
ad8ccc04
TO
64 /**
65 * @var CRM_Utils_Cache_Interface
66 */
67 protected $cache;
68
6a488035 69 /**
fe482240 70 * Constructor and getter for the singleton instance.
6a488035 71 *
72536736
AH
72 * @param bool $fresh
73 *
e97c66ff 74 * @return CRM_Utils_Hook
72536736 75 * An instance of $config->userHookClass
6a488035 76 */
00be9182 77 public static function singleton($fresh = FALSE) {
6a488035
TO
78 if (self::$_singleton == NULL || $fresh) {
79 $config = CRM_Core_Config::singleton();
80 $class = $config->userHookClass;
6a488035
TO
81 self::$_singleton = new $class();
82 }
83 return self::$_singleton;
84 }
85
f2ac86d1 86 /**
87 * CRM_Utils_Hook constructor.
e97c66ff 88 *
89 * @throws \CRM_Core_Exception
f2ac86d1 90 */
ad8ccc04 91 public function __construct() {
be2fb01f 92 $this->cache = CRM_Utils_Cache::create([
ad8ccc04 93 'name' => 'hooks',
be2fb01f 94 'type' => ['ArrayCache'],
ad8ccc04 95 'prefetch' => 1,
be2fb01f 96 ]);
ad8ccc04
TO
97 }
98
72536736 99 /**
354345c9
TO
100 * Invoke a hook through the UF/CMS hook system and the extension-hook
101 * system.
f0a7a0c9 102 *
77855840
TO
103 * @param int $numParams
104 * Number of parameters to pass to the hook.
105 * @param mixed $arg1
106 * Parameter to be passed to the hook.
107 * @param mixed $arg2
108 * Parameter to be passed to the hook.
109 * @param mixed $arg3
110 * Parameter to be passed to the hook.
111 * @param mixed $arg4
112 * Parameter to be passed to the hook.
113 * @param mixed $arg5
114 * Parameter to be passed to the hook.
115 * @param mixed $arg6
116 * Parameter to be passed to the hook.
117 * @param string $fnSuffix
118 * Function suffix, this is effectively the hook name.
72536736
AH
119 *
120 * @return mixed
121 */
6714d8d2 122 abstract public function invokeViaUF(
a3e55d9c 123 $numParams,
87dab4a4 124 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
6a488035
TO
125 $fnSuffix
126 );
127
354345c9
TO
128 /**
129 * Invoke a hook.
130 *
131 * This is a transitional adapter. It supports the legacy syntax
132 * but also accepts enough information to support Symfony Event
133 * dispatching.
134 *
20c50b07 135 * @param array $names
354345c9
TO
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.
141 * @param mixed $arg1
142 * @param mixed $arg2
143 * @param mixed $arg3
144 * @param mixed $arg4
145 * @param mixed $arg5
146 * @param mixed $arg6
147 * @param mixed $fnSuffix
148 * @return mixed
149 */
150 public function invoke(
151 $names,
152 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
153 $fnSuffix
154 ) {
ecb0ae5d
TO
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.
31177cf4 158 CRM_Core_Error::deprecatedWarning("hook_$fnSuffix should be updated to pass an array of parameter names to CRM_Utils_Hook::invoke().");
ecb0ae5d
TO
159 $compatNames = ['arg1', 'arg2', 'arg3', 'arg4', 'arg5', 'arg6'];
160 $names = array_slice($compatNames, 0, (int) $names);
161 }
162
163 $event = \Civi\Core\Event\GenericHookEvent::createOrdered(
164 $names,
20c50b07 165 [&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6]
ecb0ae5d
TO
166 );
167 \Civi::dispatcher()->dispatch('hook_' . $fnSuffix, $event);
168 return $event->getReturnValues();
354345c9
TO
169 }
170
5bc392e6 171 /**
100fef9d 172 * @param array $numParams
5bc392e6
EM
173 * @param $arg1
174 * @param $arg2
175 * @param $arg3
176 * @param $arg4
177 * @param $arg5
178 * @param $arg6
179 * @param $fnSuffix
180 * @param $fnPrefix
181 *
182 * @return array|bool
183 */
37cd2432 184 public function commonInvoke(
a3e55d9c 185 $numParams,
87dab4a4 186 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
6a488035
TO
187 $fnSuffix, $fnPrefix
188 ) {
189
190 $this->commonBuildModuleList($fnPrefix);
4636d4fd 191
6a488035 192 return $this->runHooks($this->commonCiviModules, $fnSuffix,
87dab4a4 193 $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6
6a488035
TO
194 );
195 }
196
197 /**
198 * Build the list of modules to be processed for hooks.
72536736
AH
199 *
200 * @param string $fnPrefix
6a488035 201 */
00be9182 202 public function commonBuildModuleList($fnPrefix) {
6a488035
TO
203 if (!$this->commonIncluded) {
204 // include external file
205 $this->commonIncluded = TRUE;
206
207 $config = CRM_Core_Config::singleton();
5d9bcf01
TO
208 if (!empty($config->customPHPPathDir)) {
209 $civicrmHooksFile = CRM_Utils_File::addTrailingSlash($config->customPHPPathDir) . 'civicrmHooks.php';
210 if (file_exists($civicrmHooksFile)) {
211 @include_once $civicrmHooksFile;
212 }
6a488035
TO
213 }
214
215 if (!empty($fnPrefix)) {
216 $this->commonCiviModules[$fnPrefix] = $fnPrefix;
217 }
218
219 $this->requireCiviModules($this->commonCiviModules);
220 }
221 }
222
72536736 223 /**
e97c66ff 224 * Run hooks.
225 *
226 * @param array $civiModules
227 * @param string $fnSuffix
228 * @param int $numParams
229 * @param mixed $arg1
230 * @param mixed $arg2
231 * @param mixed $arg3
232 * @param mixed $arg4
233 * @param mixed $arg5
234 * @param mixed $arg6
72536736
AH
235 *
236 * @return array|bool
ee3db087 237 * @throws \CRM_Core_Exception
72536736 238 */
37cd2432 239 public function runHooks(
a3e55d9c 240 $civiModules, $fnSuffix, $numParams,
87dab4a4 241 &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6
6a488035 242 ) {
3ac9ab1c
TO
243 // $civiModules is *not* passed by reference because runHooks
244 // must be reentrant. PHP is finicky about running
245 // multiple loops over the same variable. The circumstances
246 // to reproduce the issue are pretty intricate.
be2fb01f 247 $result = [];
6a488035 248
ad8ccc04
TO
249 $fnNames = $this->cache->get($fnSuffix);
250 if (!is_array($fnNames)) {
be2fb01f 251 $fnNames = [];
ad8ccc04
TO
252 if ($civiModules !== NULL) {
253 foreach ($civiModules as $module) {
254 $fnName = "{$module}_{$fnSuffix}";
255 if (function_exists($fnName)) {
256 $fnNames[] = $fnName;
1cba072e 257 }
4636d4fd 258 }
ad8ccc04
TO
259 $this->cache->set($fnSuffix, $fnNames);
260 }
261 }
262
263 foreach ($fnNames as $fnName) {
be2fb01f 264 $fResult = [];
ad8ccc04
TO
265 switch ($numParams) {
266 case 0:
267 $fResult = $fnName();
268 break;
269
270 case 1:
271 $fResult = $fnName($arg1);
272 break;
273
274 case 2:
275 $fResult = $fnName($arg1, $arg2);
276 break;
277
278 case 3:
279 $fResult = $fnName($arg1, $arg2, $arg3);
280 break;
281
282 case 4:
283 $fResult = $fnName($arg1, $arg2, $arg3, $arg4);
284 break;
285
286 case 5:
287 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5);
288 break;
289
290 case 6:
291 $fResult = $fnName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
292 break;
293
294 default:
ee3db087 295 throw new CRM_Core_Exception(ts('Invalid hook invocation'));
ad8ccc04
TO
296 }
297
298 if (!empty($fResult) &&
299 is_array($fResult)
300 ) {
301 $result = array_merge($result, $fResult);
6a488035
TO
302 }
303 }
304
305 return empty($result) ? TRUE : $result;
306 }
307
5bc392e6
EM
308 /**
309 * @param $moduleList
310 */
00be9182 311 public function requireCiviModules(&$moduleList) {
6a488035
TO
312 $civiModules = CRM_Core_PseudoConstant::getModuleExtensions();
313 foreach ($civiModules as $civiModule) {
314 if (!file_exists($civiModule['filePath'])) {
315 CRM_Core_Session::setStatus(
481a74f4 316 ts('Error loading module file (%1). Please restore the file or disable the module.',
be2fb01f 317 [1 => $civiModule['filePath']]),
481a74f4 318 ts('Warning'), 'error');
6a488035
TO
319 continue;
320 }
321 include_once $civiModule['filePath'];
322 $moduleList[$civiModule['prefix']] = $civiModule['prefix'];
6a488035 323 }
e7292422 324 }
6a488035
TO
325
326 /**
327 * This hook is called before a db write on some core objects.
328 * This hook does not allow the abort of the operation
329 *
77855840
TO
330 * @param string $op
331 * The type of operation being performed.
332 * @param string $objectName
333 * The name of the object.
1178ca02 334 * @param int|null $id
77855840
TO
335 * The object id if available.
336 * @param array $params
337 * The parameters used for object creation / editing.
6a488035 338 *
a6c01b45
CW
339 * @return null
340 * the return value is ignored
6a488035 341 */
be12df5a 342 public static function pre($op, $objectName, $id, &$params = []) {
fd901044 343 $event = new \Civi\Core\Event\PreEvent($op, $objectName, $id, $params);
c73e3098
TO
344 \Civi::dispatcher()->dispatch('hook_civicrm_pre', $event);
345 return $event->getReturnValues();
6a488035
TO
346 }
347
348 /**
349 * This hook is called after a db write on some core objects.
350 *
77855840
TO
351 * @param string $op
352 * The type of operation being performed.
353 * @param string $objectName
354 * The name of the object.
355 * @param int $objectId
356 * The unique identifier for the object.
357 * @param object $objectRef
358 * The reference to the object if available.
6a488035 359 *
72b3a70c
CW
360 * @return mixed
361 * based on op. pre-hooks return a boolean or
6a488035 362 * an error message which aborts the operation
6a488035 363 */
1273d77c 364 public static function post($op, $objectName, $objectId, &$objectRef = NULL) {
fd901044 365 $event = new \Civi\Core\Event\PostEvent($op, $objectName, $objectId, $objectRef);
c73e3098
TO
366 \Civi::dispatcher()->dispatch('hook_civicrm_post', $event);
367 return $event->getReturnValues();
6a488035
TO
368 }
369
74effac4
TO
370 /**
371 * This hook is equivalent to post(), except that it is guaranteed to run
372 * outside of any SQL transaction. The objectRef is not modifiable.
373 *
374 * This hook is defined for two cases:
375 *
376 * 1. If the original action runs within a transaction, then the hook fires
377 * after the transaction commits.
378 * 2. If the original action runs outside a transaction, then the data was
379 * committed immediately, and we can run the hook immediately.
380 *
381 * @param string $op
382 * The type of operation being performed.
383 * @param string $objectName
384 * The name of the object.
385 * @param int $objectId
386 * The unique identifier for the object.
387 * @param object $objectRef
388 * The reference to the object if available.
389 *
390 * @return mixed
391 * based on op. pre-hooks return a boolean or
392 * an error message which aborts the operation
393 */
394 public static function postCommit($op, $objectName, $objectId, $objectRef = NULL) {
395 $event = new \Civi\Core\Event\PostEvent($op, $objectName, $objectId, $objectRef);
396 \Civi::dispatcher()->dispatch('hook_civicrm_postCommit', $event);
397 return $event->getReturnValues();
398 }
399
6a488035 400 /**
fe482240 401 * This hook retrieves links from other modules and injects it into.
6a488035
TO
402 * the view contact tabs
403 *
77855840
TO
404 * @param string $op
405 * The type of operation being performed.
406 * @param string $objectName
407 * The name of the object.
408 * @param int $objectId
409 * The unique identifier for the object.
410 * @param array $links
411 * (optional) the links array (introduced in v3.2).
412 * @param int $mask
413 * (optional) the bitmask to show/hide links.
414 * @param array $values
415 * (optional) the values to fill the links.
6a488035 416 *
a6c01b45
CW
417 * @return null
418 * the return value is ignored
6a488035 419 */
be2fb01f
CW
420 public static function links($op, $objectName, &$objectId, &$links, &$mask = NULL, &$values = []) {
421 return self::singleton()->invoke(['op', 'objectName', 'objectId', 'links', 'mask', 'values'], $op, $objectName, $objectId, $links, $mask, $values, 'civicrm_links');
6a488035
TO
422 }
423
b2d8361e
TO
424 /**
425 * Alter the contents of a resource bundle (ie a collection of JS/CSS/etc).
426 *
427 * TIP: $bundle->add*() and $bundle->filter() should be useful for
428 * adding/removing/updating items.
429 *
430 * @param CRM_Core_Resources_Bundle $bundle
431 * @return null
432 * @see CRM_Core_Resources_CollectionInterface::add()
433 * @see CRM_Core_Resources_CollectionInterface::filter()
434 */
435 public static function alterBundle($bundle) {
436 return self::singleton()
437 ->invoke(['bundle'], $bundle, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_alterBundle');
438 }
439
21d2903d
AN
440 /**
441 * This hook is invoked during the CiviCRM form preProcess phase.
442 *
77855840
TO
443 * @param string $formName
444 * The name of the form.
445 * @param CRM_Core_Form $form
446 * Reference to the form object.
21d2903d 447 *
a6c01b45
CW
448 * @return null
449 * the return value is ignored
21d2903d 450 */
00be9182 451 public static function preProcess($formName, &$form) {
37cd2432 452 return self::singleton()
be2fb01f 453 ->invoke(['formName', 'form'], $formName, $form, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_preProcess');
21d2903d
AN
454 }
455
6a488035
TO
456 /**
457 * This hook is invoked when building a CiviCRM form. This hook should also
458 * be used to set the default values of a form element
459 *
77855840
TO
460 * @param string $formName
461 * The name of the form.
462 * @param CRM_Core_Form $form
463 * Reference to the form object.
6a488035 464 *
a6c01b45
CW
465 * @return null
466 * the return value is ignored
6a488035 467 */
00be9182 468 public static function buildForm($formName, &$form) {
be2fb01f 469 return self::singleton()->invoke(['formName', 'form'], $formName, $form,
37cd2432
TO
470 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
471 'civicrm_buildForm'
472 );
6a488035
TO
473 }
474
475 /**
476 * This hook is invoked when a CiviCRM form is submitted. If the module has injected
477 * any form elements, this hook should save the values in the database
478 *
77855840
TO
479 * @param string $formName
480 * The name of the form.
481 * @param CRM_Core_Form $form
482 * Reference to the form object.
6a488035 483 *
a6c01b45
CW
484 * @return null
485 * the return value is ignored
6a488035 486 */
00be9182 487 public static function postProcess($formName, &$form) {
be2fb01f 488 return self::singleton()->invoke(['formName', 'form'], $formName, $form,
37cd2432
TO
489 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
490 'civicrm_postProcess'
491 );
6a488035
TO
492 }
493
494 /**
495 * This hook is invoked during all CiviCRM form validation. An array of errors
6a488035
TO
496 * detected is returned. Else we assume validation succeeded.
497 *
77855840
TO
498 * @param string $formName
499 * The name of the form.
500 * @param array &$fields the POST parameters as filtered by QF
501 * @param array &$files the FILES parameters as sent in by POST
502 * @param array &$form the form object
503 * @param array &$errors the array of errors.
6a488035 504 *
72b3a70c
CW
505 * @return mixed
506 * formRule hooks return a boolean or
6a488035 507 * an array of error messages which display a QF Error
6a488035 508 */
00be9182 509 public static function validateForm($formName, &$fields, &$files, &$form, &$errors) {
37cd2432 510 return self::singleton()
be2fb01f 511 ->invoke(['formName', 'fields', 'files', 'form', 'errors'],
6a8f1687 512 $formName, $fields, $files, $form, $errors, self::$_nullObject, 'civicrm_validateForm');
6a488035
TO
513 }
514
515 /**
42bc70d4 516 * This hook is called after a db write on a custom table.
6a488035 517 *
77855840
TO
518 * @param string $op
519 * The type of operation being performed.
445bbeed 520 * @param int $groupID
77855840 521 * The custom group ID.
445bbeed 522 * @param int $entityID
77855840
TO
523 * The entityID of the row in the custom table.
524 * @param array $params
525 * The parameters that were sent into the calling function.
6a488035 526 *
a6c01b45
CW
527 * @return null
528 * the return value is ignored
6a488035 529 */
445bbeed 530 public static function custom(string $op, int $groupID, int $entityID, &$params) {
37cd2432 531 return self::singleton()
be2fb01f 532 ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self::$_nullObject, self::$_nullObject, 'civicrm_custom');
6a488035
TO
533 }
534
048b069c
BS
535 /**
536 * This hook is called before a db write on a custom table.
537 *
538 * @param string $op
539 * The type of operation being performed.
445bbeed 540 * @param int $groupID
048b069c 541 * The custom group ID.
445bbeed 542 * @param int $entityID
048b069c
BS
543 * The entityID of the row in the custom table.
544 * @param array $params
545 * The parameters that were sent into the calling function.
546 *
547 * @return null
548 * the return value is ignored
549 */
445bbeed 550 public static function customPre(string $op, int $groupID, int $entityID, array &$params) {
048b069c
BS
551 return self::singleton()
552 ->invoke(['op', 'groupID', 'entityID', 'params'], $op, $groupID, $entityID, $params, self::$_nullObject, self::$_nullObject, 'civicrm_customPre');
553 }
554
6a488035
TO
555 /**
556 * This hook is called when composing the ACL where clause to restrict
557 * visibility of contacts to the logged in user
558 *
77855840
TO
559 * @param int $type
560 * The type of permission needed.
561 * @param array $tables
562 * (reference ) add the tables that are needed for the select clause.
563 * @param array $whereTables
564 * (reference ) add the tables that are needed for the where clause.
565 * @param int $contactID
566 * The contactID for whom the check is made.
567 * @param string $where
568 * The currrent where clause.
6a488035 569 *
a6c01b45
CW
570 * @return null
571 * the return value is ignored
6a488035 572 */
00be9182 573 public static function aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where) {
37cd2432 574 return self::singleton()
be2fb01f 575 ->invoke(['type', 'tables', 'whereTables', 'contactID', 'where'], $type, $tables, $whereTables, $contactID, $where, self::$_nullObject, 'civicrm_aclWhereClause');
6a488035
TO
576 }
577
578 /**
579 * This hook is called when composing the ACL where clause to restrict
580 * visibility of contacts to the logged in user
581 *
77855840
TO
582 * @param int $type
583 * The type of permission needed.
584 * @param int $contactID
585 * The contactID for whom the check is made.
586 * @param string $tableName
587 * The tableName which is being permissioned.
588 * @param array $allGroups
589 * The set of all the objects for the above table.
590 * @param array $currentGroups
591 * The set of objects that are currently permissioned for this contact.
6a488035 592 *
a6c01b45
CW
593 * @return null
594 * the return value is ignored
6a488035 595 */
00be9182 596 public static function aclGroup($type, $contactID, $tableName, &$allGroups, &$currentGroups) {
37cd2432 597 return self::singleton()
be2fb01f 598 ->invoke(['type', 'contactID', 'tableName', 'allGroups', 'currentGroups'], $type, $contactID, $tableName, $allGroups, $currentGroups, self::$_nullObject, 'civicrm_aclGroup');
6a488035
TO
599 }
600
032346cc
CW
601 /**
602 * @param string|CRM_Core_DAO $entity
603 * @param array $clauses
604 * @return mixed
605 */
606 public static function selectWhereClause($entity, &$clauses) {
607 $entityName = is_object($entity) ? _civicrm_api_get_entity_name_from_dao($entity) : $entity;
be2fb01f 608 return self::singleton()->invoke(['entity', 'clauses'], $entityName, $clauses,
032346cc
CW
609 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
610 'civicrm_selectWhereClause'
611 );
612 }
613
6a488035 614 /**
fe482240 615 * This hook is called when building the menu table.
6a488035 616 *
77855840
TO
617 * @param array $files
618 * The current set of files to process.
6a488035 619 *
a6c01b45
CW
620 * @return null
621 * the return value is ignored
6a488035 622 */
00be9182 623 public static function xmlMenu(&$files) {
be2fb01f 624 return self::singleton()->invoke(['files'], $files,
87dab4a4 625 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
626 'civicrm_xmlMenu'
627 );
628 }
629
7dc34fb8
TO
630 /**
631 * (Experimental) This hook is called when build the menu table.
632 *
633 * @param array $items
634 * List of records to include in menu table.
635 * @return null
636 * the return value is ignored
637 */
638 public static function alterMenu(&$items) {
be2fb01f 639 return self::singleton()->invoke(['items'], $items,
7dc34fb8
TO
640 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
641 'civicrm_alterMenu'
642 );
643 }
644
d89d2545
TO
645 /**
646 * A theme is a set of CSS files which are loaded on CiviCRM pages. To register a new
647 * theme, add it to the $themes array. Use these properties:
648 *
649 * - ext: string (required)
650 * The full name of the extension which defines the theme.
651 * Ex: "org.civicrm.themes.greenwich".
652 * - title: string (required)
653 * Visible title.
654 * - help: string (optional)
655 * Description of the theme's appearance.
656 * - url_callback: mixed (optional)
657 * A function ($themes, $themeKey, $cssExt, $cssFile) which returns the URL(s) for a CSS resource.
658 * Returns either an array of URLs or PASSTHRU.
659 * Ex: \Civi\Core\Themes\Resolvers::simple (default)
660 * Ex: \Civi\Core\Themes\Resolvers::none
661 * - prefix: string (optional)
662 * A prefix within the extension folder to prepend to the file name.
663 * - search_order: array (optional)
664 * A list of themes to search.
665 * Generally, the last theme should be "*fallback*" (Civi\Core\Themes::FALLBACK).
666 * - excludes: array (optional)
667 * A list of files (eg "civicrm:css/bootstrap.css" or "$ext:$file") which should never
668 * be returned (they are excluded from display).
669 *
670 * @param array $themes
671 * List of themes, keyed by name.
672 * @return null
673 * the return value is ignored
674 */
675 public static function themes(&$themes) {
41344661 676 return self::singleton()->invoke(['themes'], $themes,
d89d2545
TO
677 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
678 'civicrm_themes'
679 );
680 }
681
682 /**
683 * The activeTheme hook determines which theme is active.
684 *
685 * @param string $theme
686 * The identifier for the theme. Alterable.
687 * Ex: 'greenwich'.
688 * @param array $context
689 * Information about the current page-request. Includes some mix of:
690 * - page: the relative path of the current Civi page (Ex: 'civicrm/dashboard').
691 * - themes: an instance of the Civi\Core\Themes service.
692 * @return null
693 * the return value is ignored
694 */
695 public static function activeTheme(&$theme, $context) {
20c50b07 696 return self::singleton()->invoke(['theme', 'context'], $theme, $context,
d89d2545
TO
697 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
698 'civicrm_activeTheme'
699 );
700 }
701
6a488035 702 /**
88718db2 703 * This hook is called for declaring managed entities via API.
6a488035 704 *
fdc67a75
TO
705 * @code
706 * // Example: Optimal skeleton for backward/forward compatibility
707 * function example_civicrm_managed(&$entities, ?array $modules = NULL) {
708 * if ($modules !== NULL && !in_array(E::LONG_NAME, $modules, TRUE)) {
709 * return;
710 * }
711 * $entities[] = [
712 * 'module' => E::LONG_NAME,
713 * 'name' => 'my_option_value',
714 * 'entity' => 'OptionValue',
715 * 'params' => [...],
716 * ];
717 * }
718 * @endCode
719 *
77855840 720 * @param array $entities
88718db2
TO
721 * List of pending entities. Each entity is an array with keys:
722 * + '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")
723 * + 'name': string, a symbolic name which can be used to track this entity (Note: Each module creates its own namespace)
724 * + 'entity': string, an entity-type supported by the CiviCRM API (Note: this currently must be an entity which supports the 'is_active' property)
725 * + 'params': array, the entity data as supported by the CiviCRM API
726 * + 'update' (v4.5+): string, a policy which describes when to update records
727 * - 'always' (default): always update the managed-entity record; changes in $entities will override any local changes (eg by the site-admin)
728 * - 'never': never update the managed-entity record; changes made locally (eg by the site-admin) will override changes in $entities
729 * + '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)
730 * - 'always' (default): always delete orphaned records
731 * - 'never': never delete orphaned records
732 * - '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.)
fdc67a75
TO
733 * @param array|NULL $modules
734 * (Added circa v5.50) If given, only report entities related to $modules. NULL is a wildcard ("all modules").
6a488035 735 *
fdc67a75
TO
736 * This parameter is _advisory_ and is not supplied on older versions.
737 * Listeners SHOULD self-censor (only report entities which match the filter).
738 * However, all pre-existing listeners were unaware of this option, and they WILL over-report.
739 * Over-reported data will be discarded.
a6c01b45
CW
740 * @return null
741 * the return value is ignored
6a488035 742 */
fdc67a75
TO
743 public static function managed(&$entities, ?array $modules = NULL) {
744 self::singleton()->invoke(['entities', 'modules'], $entities, $modules,
745 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
746 'civicrm_managed'
747 );
fdc67a75 748 if ($modules) {
15fbb541
TO
749 $entities = array_filter($entities, function($entity) use ($modules) {
750 return in_array($entity['module'], $modules, TRUE);
fdc67a75
TO
751 });
752 }
6a488035
TO
753 }
754
755 /**
756 * This hook is called when rendering the dashboard (q=civicrm/dashboard)
757 *
77855840
TO
758 * @param int $contactID
759 * The contactID for whom the dashboard is being rendered.
760 * @param int $contentPlacement
761 * (output parameter) where should the hook content be displayed.
9399901d 762 * relative to the activity list
6a488035 763 *
a6c01b45
CW
764 * @return string
765 * the html snippet to include in the dashboard
6a488035 766 */
00be9182 767 public static function dashboard($contactID, &$contentPlacement = self::DASHBOARD_BELOW) {
be2fb01f 768 $retval = self::singleton()->invoke(['contactID', 'contentPlacement'], $contactID, $contentPlacement,
87dab4a4 769 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
770 'civicrm_dashboard'
771 );
772
773 /*
774 * Note we need this seemingly unnecessary code because in the event that the implementation
775 * of the hook declares the second parameter but doesn't set it, then it comes back unset even
776 * though we have a default value in this function's declaration above.
777 */
778 if (!isset($contentPlacement)) {
779 $contentPlacement = self::DASHBOARD_BELOW;
780 }
781
782 return $retval;
783 }
784
785 /**
786 * This hook is called before storing recently viewed items.
787 *
77855840
TO
788 * @param array $recentArray
789 * An array of recently viewed or processed items, for in place modification.
6a488035
TO
790 *
791 * @return array
6a488035 792 */
00be9182 793 public static function recent(&$recentArray) {
be2fb01f 794 return self::singleton()->invoke(['recentArray'], $recentArray,
87dab4a4 795 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
796 'civicrm_recent'
797 );
798 }
799
91dee34b 800 /**
fe482240 801 * Determine how many other records refer to a given record.
91dee34b 802 *
77855840
TO
803 * @param CRM_Core_DAO $dao
804 * The item for which we want a reference count.
805 * @param array $refCounts
16b10e64 806 * Each item in the array is an Array with keys:
91dee34b
TO
807 * - name: string, eg "sql:civicrm_email:contact_id"
808 * - type: string, eg "sql"
809 * - count: int, eg "5" if there are 5 email addresses that refer to $dao
153b262f
EM
810 *
811 * @return mixed
812 * Return is not really intended to be used.
91dee34b 813 */
00be9182 814 public static function referenceCounts($dao, &$refCounts) {
be2fb01f 815 return self::singleton()->invoke(['dao', 'refCounts'], $dao, $refCounts,
91dee34b
TO
816 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
817 'civicrm_referenceCounts'
818 );
819 }
820
6a488035 821 /**
fe482240 822 * This hook is called when building the amount structure for a Contribution or Event Page.
6a488035 823 *
77855840
TO
824 * @param int $pageType
825 * Is this a contribution or event page.
826 * @param CRM_Core_Form $form
827 * Reference to the form object.
828 * @param array $amount
829 * The amount structure to be displayed.
6a488035
TO
830 *
831 * @return null
6a488035 832 */
00be9182 833 public static function buildAmount($pageType, &$form, &$amount) {
be2fb01f 834 return self::singleton()->invoke(['pageType', 'form', 'amount'], $pageType, $form, $amount, self::$_nullObject,
87dab4a4 835 self::$_nullObject, self::$_nullObject, 'civicrm_buildAmount');
6a488035
TO
836 }
837
838 /**
839 * This hook is called when building the state list for a particular country.
840 *
72536736
AH
841 * @param array $countryID
842 * The country id whose states are being selected.
843 * @param $states
6a488035
TO
844 *
845 * @return null
6a488035 846 */
00be9182 847 public static function buildStateProvinceForCountry($countryID, &$states) {
be2fb01f 848 return self::singleton()->invoke(['countryID', 'states'], $countryID, $states,
87dab4a4 849 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
850 'civicrm_buildStateProvinceForCountry'
851 );
852 }
853
fa3dbfbd 854 /**
72536736
AH
855 * This hook is called when rendering the tabs used for events and potentially
856 * contribution pages, etc.
857 *
858 * @param string $tabsetName
859 * Name of the screen or visual element.
860 * @param array $tabs
861 * Tabs that will be displayed.
862 * @param array $context
863 * Extra data about the screen or context in which the tab is used.
fa3dbfbd 864 *
2efcf0c2 865 * @return null
fa3dbfbd 866 */
00be9182 867 public static function tabset($tabsetName, &$tabs, $context) {
be2fb01f 868 return self::singleton()->invoke(['tabsetName', 'tabs', 'context'], $tabsetName, $tabs,
87dab4a4 869 $context, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tabset'
fa3dbfbd 870 );
871 }
872
6a488035
TO
873 /**
874 * This hook is called when sending an email / printing labels
875 *
77855840
TO
876 * @param array $tokens
877 * The list of tokens that can be used for the contact.
6a488035
TO
878 *
879 * @return null
6a488035 880 */
00be9182 881 public static function tokens(&$tokens) {
be2fb01f 882 return self::singleton()->invoke(['tokens'], $tokens,
87dab4a4 883 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_tokens'
6a488035
TO
884 );
885 }
886
8f4eb478 887 /**
888 * This hook allows modification of the admin panels
889 *
890 * @param array $panels
891 * Associated array of admin panels
892 *
893 * @return mixed
894 */
895 public static function alterAdminPanel(&$panels) {
20c50b07 896 return self::singleton()->invoke(['panels'], $panels,
8f4eb478 897 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
898 'civicrm_alterAdminPanel'
899 );
900 }
901
6a488035
TO
902 /**
903 * This hook is called when sending an email / printing labels to get the values for all the
904 * tokens returned by the 'tokens' hook
905 *
77855840 906 * @param array $details
590111ef 907 * The array to store the token values indexed by contactIDs.
77855840
TO
908 * @param array $contactIDs
909 * An array of contactIDs.
910 * @param int $jobID
911 * The jobID if this is associated with a CiviMail mailing.
912 * @param array $tokens
913 * The list of tokens associated with the content.
914 * @param string $className
915 * The top level className from where the hook is invoked.
6a488035
TO
916 *
917 * @return null
6a488035 918 */
37cd2432 919 public static function tokenValues(
a3e55d9c 920 &$details,
6a488035 921 $contactIDs,
e7292422 922 $jobID = NULL,
be2fb01f 923 $tokens = [],
6a488035
TO
924 $className = NULL
925 ) {
37cd2432 926 return self::singleton()
be2fb01f 927 ->invoke(['details', 'contactIDs', 'jobID', 'tokens', 'className'], $details, $contactIDs, $jobID, $tokens, $className, self::$_nullObject, 'civicrm_tokenValues');
6a488035
TO
928 }
929
930 /**
931 * This hook is called before a CiviCRM Page is rendered. You can use this hook to insert smarty variables
932 * in a template
933 *
77855840
TO
934 * @param object $page
935 * The page that will be rendered.
6a488035
TO
936 *
937 * @return null
6a488035 938 */
00be9182 939 public static function pageRun(&$page) {
be2fb01f 940 return self::singleton()->invoke(['page'], $page,
87dab4a4 941 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
942 'civicrm_pageRun'
943 );
944 }
945
946 /**
947 * This hook is called after a copy of an object has been made. The current objects are
948 * Event, Contribution Page and UFGroup
949 *
77855840
TO
950 * @param string $objectName
951 * Name of the object.
952 * @param object $object
953 * Reference to the copy.
6a488035
TO
954 *
955 * @return null
6a488035 956 */
00be9182 957 public static function copy($objectName, &$object) {
be2fb01f 958 return self::singleton()->invoke(['objectName', 'object'], $objectName, $object,
87dab4a4 959 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
960 'civicrm_copy'
961 );
962 }
963
964 /**
965 * This hook is called when a contact unsubscribes from a mailing. It allows modules
966 * to override what the contacts are removed from.
967 *
72536736
AH
968 * @param string $op
969 * Ignored for now
970 * @param int $mailingId
971 * The id of the mailing to unsub from
972 * @param int $contactId
973 * The id of the contact who is unsubscribing
974 * @param array|int $groups
975 * Groups the contact will be removed from.
976 * @param array|int $baseGroups
977 * Base groups (used in smart mailings) the contact will be removed from.
978 *
dcbd3a55 979 *
72536736
AH
980 * @return mixed
981 */
00be9182 982 public static function unsubscribeGroups($op, $mailingId, $contactId, &$groups, &$baseGroups) {
37cd2432 983 return self::singleton()
be2fb01f 984 ->invoke(['op', 'mailingId', 'contactId', 'groups', 'baseGroups'], $op, $mailingId, $contactId, $groups, $baseGroups, self::$_nullObject, 'civicrm_unsubscribeGroups');
6a488035
TO
985 }
986
987 /**
6eb95671
CW
988 * This hook is called when CiviCRM needs to edit/display a custom field with options
989 *
990 * @deprecated in favor of hook_civicrm_fieldOptions
6a488035 991 *
77855840
TO
992 * @param int $customFieldID
993 * The custom field ID.
994 * @param array $options
995 * The current set of options for that custom field.
6a488035 996 * You can add/remove existing options.
9399901d
KJ
997 * Important: This array may contain meta-data about the field that is needed elsewhere, so it is important
998 * to be careful to not overwrite the array.
6a488035 999 * Only add/edit/remove the specific field options you intend to affect.
77855840 1000 * @param bool $detailedFormat
6eb95671 1001 * If true, the options are in an ID => array ( 'id' => ID, 'label' => label, 'value' => value ) format
77855840
TO
1002 * @param array $selectAttributes
1003 * Contain select attribute(s) if any.
72536736
AH
1004 *
1005 * @return mixed
6a488035 1006 */
be2fb01f 1007 public static function customFieldOptions($customFieldID, &$options, $detailedFormat = FALSE, $selectAttributes = []) {
9c42b57d 1008 // Weird: $selectAttributes is inputted but not outputted.
be2fb01f 1009 return self::singleton()->invoke(['customFieldID', 'options', 'detailedFormat'], $customFieldID, $options, $detailedFormat,
87dab4a4 1010 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1011 'civicrm_customFieldOptions'
1012 );
1013 }
1014
33e61cb8
CW
1015 /**
1016 * Hook for modifying field options
1017 *
1018 * @param string $entity
1019 * @param string $field
1020 * @param array $options
1021 * @param array $params
1022 *
1023 * @return mixed
1024 */
1025 public static function fieldOptions($entity, $field, &$options, $params) {
be2fb01f 1026 return self::singleton()->invoke(['entity', 'field', 'options', 'params'], $entity, $field, $options, $params,
33e61cb8
CW
1027 self::$_nullObject, self::$_nullObject,
1028 'civicrm_fieldOptions'
1029 );
1030 }
1031
6a488035
TO
1032 /**
1033 *
1034 * This hook is called to display the list of actions allowed after doing a search.
1035 * This allows the module developer to inject additional actions or to remove existing actions.
1036 *
77855840
TO
1037 * @param string $objectType
1038 * The object type for this search.
6a488035 1039 * - activity, campaign, case, contact, contribution, event, grant, membership, and pledge are supported.
77855840
TO
1040 * @param array $tasks
1041 * The current set of tasks for that custom field.
6a488035 1042 * You can add/remove existing tasks.
7f82e636 1043 * Each task needs to have a title (eg 'title' => ts( 'Group - add contacts')) and a class
9399901d 1044 * (eg 'class' => 'CRM_Contact_Form_Task_AddToGroup').
6a488035 1045 * Optional result (boolean) may also be provided. Class can be an array of classes (not sure what that does :( ).
9399901d
KJ
1046 * The key for new Task(s) should not conflict with the keys for core tasks of that $objectType, which can be
1047 * found in CRM/$objectType/Task.php.
72536736
AH
1048 *
1049 * @return mixed
6a488035 1050 */
00be9182 1051 public static function searchTasks($objectType, &$tasks) {
be2fb01f 1052 return self::singleton()->invoke(['objectType', 'tasks'], $objectType, $tasks,
87dab4a4 1053 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1054 'civicrm_searchTasks'
1055 );
1056 }
1057
72536736
AH
1058 /**
1059 * @param mixed $form
1060 * @param array $params
1061 *
1062 * @return mixed
1063 */
00be9182 1064 public static function eventDiscount(&$form, &$params) {
be2fb01f 1065 return self::singleton()->invoke(['form', 'params'], $form, $params,
87dab4a4 1066 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1067 'civicrm_eventDiscount'
1068 );
1069 }
1070
5f68c8c8
TO
1071 /**
1072 * When adding a new "Mail Account" (`MailSettings`), present a menu of setup
1073 * options.
1074 *
1075 * @param array $setupActions
1076 * Each item has a symbolic-key, and it has the properties:
1077 * - title: string
1078 * - callback: string|array, the function which starts the setup process.
1079 * The function is expected to return a 'url' for the config screen.
1080 * @return mixed
1081 */
1082 public static function mailSetupActions(&$setupActions) {
1083 return self::singleton()->invoke(['setupActions'], $setupActions, self::$_nullObject, self::$_nullObject,
1084 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1085 'civicrm_mailSetupActions'
1086 );
1087 }
1088
6a488035
TO
1089 /**
1090 * This hook is called when composing a mailing. You can include / exclude other groups as needed.
1091 *
72536736
AH
1092 * @param mixed $form
1093 * The form object for which groups / mailings being displayed
1094 * @param array $groups
1095 * The list of groups being included / excluded
1096 * @param array $mailings
1097 * The list of mailings being included / excluded
1098 *
1099 * @return mixed
6a488035 1100 */
00be9182 1101 public static function mailingGroups(&$form, &$groups, &$mailings) {
be2fb01f 1102 return self::singleton()->invoke(['form', 'groups', 'mailings'], $form, $groups, $mailings,
87dab4a4 1103 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1104 'civicrm_mailingGroups'
1105 );
1106 }
1107
703875d8
TO
1108 /**
1109 * (Experimental) Modify the list of template-types used for CiviMail composition.
1110 *
1111 * @param array $types
1112 * Sequentially indexed list of template types. Each type specifies:
1113 * - name: string
1114 * - editorUrl: string, Angular template URL
1115 * - weight: int, priority when picking a default value for new mailings
1116 * @return mixed
1117 */
1118 public static function mailingTemplateTypes(&$types) {
be2fb01f 1119 return self::singleton()->invoke(['types'], $types, self::$_nullObject, self::$_nullObject,
703875d8
TO
1120 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1121 'civicrm_mailingTemplateTypes'
1122 );
1123 }
1124
6a488035 1125 /**
9399901d
KJ
1126 * This hook is called when composing the array of membershipTypes and their cost during a membership registration
1127 * (new or renewal).
6a488035
TO
1128 * Note the hook is called on initial page load and also reloaded after submit (PRG pattern).
1129 * You can use it to alter the membership types when first loaded, or after submission
1130 * (for example if you want to gather data in the form and use it to alter the fees).
1131 *
72536736
AH
1132 * @param mixed $form
1133 * The form object that is presenting the page
1134 * @param array $membershipTypes
1135 * The array of membership types and their amount
1136 *
1137 * @return mixed
6a488035 1138 */
00be9182 1139 public static function membershipTypeValues(&$form, &$membershipTypes) {
be2fb01f 1140 return self::singleton()->invoke(['form', 'membershipTypes'], $form, $membershipTypes,
87dab4a4 1141 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1142 'civicrm_membershipTypeValues'
1143 );
1144 }
1145
1146 /**
fe482240 1147 * This hook is called when rendering the contact summary.
6a488035 1148 *
72536736
AH
1149 * @param int $contactID
1150 * The contactID for whom the summary is being rendered
1151 * @param mixed $content
1152 * @param int $contentPlacement
1153 * Specifies where the hook content should be displayed relative to the
1154 * existing content
6a488035 1155 *
72536736
AH
1156 * @return string
1157 * The html snippet to include in the contact summary
6a488035 1158 */
00be9182 1159 public static function summary($contactID, &$content, &$contentPlacement = self::SUMMARY_BELOW) {
be2fb01f 1160 return self::singleton()->invoke(['contactID', 'content', 'contentPlacement'], $contactID, $content, $contentPlacement,
87dab4a4 1161 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1162 'civicrm_summary'
1163 );
1164 }
1165
1166 /**
1167 * Use this hook to populate the list of contacts returned by Contact Reference custom fields.
1168 * By default, Contact Reference fields will search on and return all CiviCRM contacts.
1169 * If you want to limit the contacts returned to a specific group, or some other criteria
1170 * - you can override that behavior by providing a SQL query that returns some subset of your contacts.
1171 * The hook is called when the query is executed to get the list of contacts to display.
1172 *
77855840
TO
1173 * @param mixed $query
1174 * - the query that will be executed (input and output parameter);.
6a488035
TO
1175 * It's important to realize that the ACL clause is built prior to this hook being fired,
1176 * so your query will ignore any ACL rules that may be defined.
1177 * Your query must return two columns:
1178 * the contact 'data' to display in the autocomplete dropdown (usually contact.sort_name - aliased as 'data')
1179 * the contact IDs
0fcad357 1180 * @param string $queryText
77855840
TO
1181 * The name string to execute the query against (this is the value being typed in by the user).
1182 * @param string $context
1183 * The context in which this ajax call is being made (for example: 'customfield', 'caseview').
1184 * @param int $id
1185 * The id of the object for which the call is being made.
6a488035 1186 * For custom fields, it will be the custom field id
72536736
AH
1187 *
1188 * @return mixed
6a488035 1189 */
0fcad357 1190 public static function contactListQuery(&$query, $queryText, $context, $id) {
be2fb01f 1191 return self::singleton()->invoke(['query', 'queryText', 'context', 'id'], $query, $queryText, $context, $id,
87dab4a4 1192 self::$_nullObject, self::$_nullObject,
6a488035
TO
1193 'civicrm_contactListQuery'
1194 );
1195 }
1196
1197 /**
1198 * Hook definition for altering payment parameters before talking to a payment processor back end.
1199 *
1200 * Definition will look like this:
1201 *
153b262f
EM
1202 * function hook_civicrm_alterPaymentProcessorParams(
1203 * $paymentObj,
1204 * &$rawParams,
1205 * &$cookedParams
1206 * );
80bcd255 1207 *
153b262f
EM
1208 * @param CRM_Core_Payment $paymentObj
1209 * Instance of payment class of the payment processor invoked (e.g., 'CRM_Core_Payment_Dummy')
1210 * See discussion in CRM-16224 as to whether $paymentObj should be passed by reference.
613aa101 1211 * @param array|\Civi\Payment\PropertyBag &$rawParams
6a488035 1212 * array of params as passed to to the processor
3bfefe56 1213 * @param array|\Civi\Payment\PropertyBag &$cookedParams
6a488035
TO
1214 * params after the processor code has translated them into its own key/value pairs
1215 *
72536736 1216 * @return mixed
80bcd255 1217 * This return is not really intended to be used.
6a488035 1218 */
37cd2432 1219 public static function alterPaymentProcessorParams(
a3e55d9c 1220 $paymentObj,
6a488035
TO
1221 &$rawParams,
1222 &$cookedParams
1223 ) {
be2fb01f 1224 return self::singleton()->invoke(['paymentObj', 'rawParams', 'cookedParams'], $paymentObj, $rawParams, $cookedParams,
87dab4a4 1225 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1226 'civicrm_alterPaymentProcessorParams'
1227 );
1228 }
1229
1230 /**
1231 * This hook is called when an email is about to be sent by CiviCRM.
1232 *
72536736
AH
1233 * @param array $params
1234 * Array fields include: groupName, from, toName, toEmail, subject, cc, bcc, text, html,
16b10e64 1235 * returnPath, replyTo, headers, attachments (array)
77855840
TO
1236 * @param string $context
1237 * The context in which the hook is being invoked, eg 'civimail'.
72536736
AH
1238 *
1239 * @return mixed
6a488035 1240 */
00be9182 1241 public static function alterMailParams(&$params, $context = NULL) {
be2fb01f 1242 return self::singleton()->invoke(['params', 'context'], $params, $context,
87dab4a4 1243 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1244 'civicrm_alterMailParams'
1245 );
1246 }
1247
f928a0b0
TO
1248 /**
1249 * This hook is called when loading a mail-store (e.g. IMAP, POP3, or Maildir).
1250 *
1251 * @param array $params
1252 * Most fields correspond to data in the MailSettings entity:
1253 * - id: int
1254 * - server: string
1255 * - username: string
1256 * - password: string
1257 * - is_ssl: bool
1258 * - source: string
1259 * - local_part: string
1260 *
1261 * With a few supplements
1262 * - protocol: string, symbolic protocol name (e.g. "IMAP")
1263 * - factory: callable, the function which instantiates the driver class
1264 * - auth: string, (for some drivers) specify the authentication method (eg "Password" or "XOAuth2")
1265 *
1266 * @return mixed
1267 */
1268 public static function alterMailStore(&$params) {
1269 return self::singleton()->invoke(['params'], $params, $context,
1270 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1271 'civicrm_alterMailStore'
1272 );
1273 }
1274
5f11bbcc 1275 /**
fe482240 1276 * This hook is called when membership status is being calculated.
5f11bbcc 1277 *
77855840
TO
1278 * @param array $membershipStatus
1279 * Membership status details as determined - alter if required.
1280 * @param array $arguments
1281 * Arguments passed in to calculate date.
5f11bbcc
EM
1282 * - 'start_date'
1283 * - 'end_date'
1284 * - 'status_date'
1285 * - 'join_date'
1286 * - 'exclude_is_admin'
1287 * - 'membership_type_id'
77855840
TO
1288 * @param array $membership
1289 * Membership details from the calling function.
f4aaa82a
EM
1290 *
1291 * @return mixed
5f11bbcc 1292 */
00be9182 1293 public static function alterCalculatedMembershipStatus(&$membershipStatus, $arguments, $membership) {
be2fb01f 1294 return self::singleton()->invoke(['membershipStatus', 'arguments', 'membership'], $membershipStatus, $arguments,
fc6a608f 1295 $membership, self::$_nullObject, self::$_nullObject, self::$_nullObject,
5f11bbcc
EM
1296 'civicrm_alterCalculatedMembershipStatus'
1297 );
1298 }
1299
d04a3a9b 1300 /**
1301 * This hook is called after getting the content of the mail and before tokenizing it.
1302 *
d1719f82 1303 * @param array $content
d04a3a9b 1304 * Array fields include: html, text, subject
1305 *
1306 * @return mixed
1307 */
d1719f82 1308 public static function alterMailContent(&$content) {
be2fb01f 1309 return self::singleton()->invoke(['content'], $content,
d04a3a9b 1310 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
d1719f82 1311 'civicrm_alterMailContent'
d04a3a9b 1312 );
1313 }
1314
6a488035 1315 /**
fe482240 1316 * This hook is called when rendering the Manage Case screen.
6a488035 1317 *
77855840
TO
1318 * @param int $caseID
1319 * The case ID.
6a488035 1320 *
a6c01b45 1321 * @return array
16b10e64
CW
1322 * Array of data to be displayed, where the key is a unique id to be used for styling (div id's)
1323 * and the value is an array with keys 'label' and 'value' specifying label/value pairs
6a488035 1324 */
00be9182 1325 public static function caseSummary($caseID) {
be2fb01f 1326 return self::singleton()->invoke(['caseID'], $caseID,
87dab4a4 1327 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1328 'civicrm_caseSummary'
1329 );
1330 }
1331
6b86870e
TO
1332 /**
1333 * This hook is called when locating CiviCase types.
1334 *
1335 * @param array $caseTypes
72536736
AH
1336 *
1337 * @return mixed
6b86870e 1338 */
00be9182 1339 public static function caseTypes(&$caseTypes) {
37cd2432 1340 return self::singleton()
be2fb01f 1341 ->invoke(['caseTypes'], $caseTypes, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_caseTypes');
6b86870e
TO
1342 }
1343
f945f0c4
I
1344 /**
1345 * This hook is called when getting case email subject patterns.
1346 *
1347 * All emails related to cases have case hash/id in the subject, e.g:
1348 * [case #ab12efg] Magic moment
1349 * [case #1234] Magic is here
1350 *
1351 * Using this hook you can replace/enrich default list with some other
1352 * patterns, e.g. include case type categories (see CiviCase extension) like:
1353 * [(case|project|policy initiative) #hash]
1354 * [(case|project|policy initiative) #id]
1355 *
1356 * @param array $subjectPatterns
1357 * Cases related email subject regexp patterns.
1358 *
1359 * @return mixed
1360 */
1361 public static function caseEmailSubjectPatterns(&$subjectPatterns) {
1362 return self::singleton()
1363 ->invoke(['caseEmailSubjectPatterns'], $subjectPatterns, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_caseEmailSubjectPatterns');
1364 }
1365
6a488035
TO
1366 /**
1367 * This hook is called soon after the CRM_Core_Config object has ben initialized.
1368 * You can use this hook to modify the config object and hence behavior of CiviCRM dynamically.
72536736
AH
1369 *
1370 * @param CRM_Core_Config|array $config
1371 * The config object
1372 *
1373 * @return mixed
6a488035 1374 */
00be9182 1375 public static function config(&$config) {
be2fb01f 1376 return self::singleton()->invoke(['config'], $config,
87dab4a4 1377 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1378 'civicrm_config'
1379 );
1380 }
1381
6a488035 1382 /**
fe482240 1383 * This hooks allows to change option values.
6a488035 1384 *
6eb95671
CW
1385 * @deprecated in favor of hook_civicrm_fieldOptions
1386 *
72536736
AH
1387 * @param array $options
1388 * Associated array of option values / id
0fcad357 1389 * @param string $groupName
72536736 1390 * Option group name
6a488035 1391 *
72536736 1392 * @return mixed
6a488035 1393 */
0fcad357 1394 public static function optionValues(&$options, $groupName) {
be2fb01f 1395 return self::singleton()->invoke(['options', 'groupName'], $options, $groupName,
87dab4a4 1396 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1397 'civicrm_optionValues'
1398 );
1399 }
1400
1401 /**
1402 * This hook allows modification of the navigation menu.
1403 *
72536736
AH
1404 * @param array $params
1405 * Associated array of navigation menu entry to Modify/Add
1406 *
1407 * @return mixed
6a488035 1408 */
00be9182 1409 public static function navigationMenu(&$params) {
be2fb01f 1410 return self::singleton()->invoke(['params'], $params,
87dab4a4 1411 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1412 'civicrm_navigationMenu'
1413 );
1414 }
1415
1416 /**
1417 * This hook allows modification of the data used to perform merging of duplicates.
1418 *
77855840
TO
1419 * @param string $type
1420 * The type of data being passed (cidRefs|eidRefs|relTables|sqls).
1421 * @param array $data
1422 * The data, as described in $type.
1423 * @param int $mainId
1424 * Contact_id of the contact that survives the merge.
1425 * @param int $otherId
1426 * Contact_id of the contact that will be absorbed and deleted.
1427 * @param array $tables
1428 * When $type is "sqls", an array of tables as it may have been handed to the calling function.
6a488035 1429 *
72536736 1430 * @return mixed
6a488035 1431 */
00be9182 1432 public static function merge($type, &$data, $mainId = NULL, $otherId = NULL, $tables = NULL) {
be2fb01f 1433 return self::singleton()->invoke(['type', 'data', 'mainId', 'otherId', 'tables'], $type, $data, $mainId, $otherId, $tables, self::$_nullObject, 'civicrm_merge');
6a488035
TO
1434 }
1435
92a77772 1436 /**
1437 * This hook allows modification of the data calculated for merging locations.
1438 *
1439 * @param array $blocksDAO
1440 * Array of location DAO to be saved. These are arrays in 2 keys 'update' & 'delete'.
1441 * @param int $mainId
1442 * Contact_id of the contact that survives the merge.
1443 * @param int $otherId
1444 * Contact_id of the contact that will be absorbed and deleted.
1445 * @param array $migrationInfo
1446 * Calculated migration info, informational only.
1447 *
1448 * @return mixed
1449 */
1450 public static function alterLocationMergeData(&$blocksDAO, $mainId, $otherId, $migrationInfo) {
be2fb01f 1451 return self::singleton()->invoke(['blocksDAO', 'mainId', 'otherId', 'migrationInfo'], $blocksDAO, $mainId, $otherId, $migrationInfo, self::$_nullObject, self::$_nullObject, 'civicrm_alterLocationMergeData');
92a77772 1452 }
1453
6a488035
TO
1454 /**
1455 * This hook provides a way to override the default privacy behavior for notes.
1456 *
72536736
AH
1457 * @param array &$noteValues
1458 * Associative array of values for this note
6a488035 1459 *
72536736 1460 * @return mixed
6a488035 1461 */
00be9182 1462 public static function notePrivacy(&$noteValues) {
be2fb01f 1463 return self::singleton()->invoke(['noteValues'], $noteValues,
87dab4a4 1464 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1465 'civicrm_notePrivacy'
1466 );
1467 }
1468
1469 /**
fe482240 1470 * This hook is called before record is exported as CSV.
6a488035 1471 *
77855840
TO
1472 * @param string $exportTempTable
1473 * Name of the temporary export table used during export.
1474 * @param array $headerRows
1475 * Header rows for output.
1476 * @param array $sqlColumns
1477 * SQL columns.
1478 * @param int $exportMode
1479 * Export mode ( contact, contribution, etc...).
a09323e9 1480 * @param string $componentTable
1481 * Name of temporary table
1482 * @param array $ids
1483 * Array of object's ids
6a488035 1484 *
72536736 1485 * @return mixed
6a488035 1486 */
ca934663 1487 public static function export(&$exportTempTable, &$headerRows, &$sqlColumns, $exportMode, $componentTable, $ids) {
be2fb01f 1488 return self::singleton()->invoke(['exportTempTable', 'headerRows', 'sqlColumns', 'exportMode', 'componentTable', 'ids'],
a09323e9 1489 $exportTempTable, $headerRows, $sqlColumns,
1490 $exportMode, $componentTable, $ids,
6a488035
TO
1491 'civicrm_export'
1492 );
1493 }
1494
1495 /**
1496 * This hook allows modification of the queries constructed from dupe rules.
1497 *
77855840
TO
1498 * @param string $obj
1499 * Object of rulegroup class.
1500 * @param string $type
1501 * Type of queries e.g table / threshold.
1502 * @param array $query
1503 * Set of queries.
6a488035 1504 *
f4aaa82a 1505 * @return mixed
6a488035 1506 */
00be9182 1507 public static function dupeQuery($obj, $type, &$query) {
be2fb01f 1508 return self::singleton()->invoke(['obj', 'type', 'query'], $obj, $type, $query,
87dab4a4 1509 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1510 'civicrm_dupeQuery'
1511 );
1512 }
1513
b8cb7e46
MWMC
1514 /**
1515 * Check for duplicate contacts
1516 *
1517 * @param array $dedupeParams
1518 * Array of params for finding duplicates: [
1519 * '{parameters returned by CRM_Dedupe_Finder::formatParams}
1520 * 'check_permission' => TRUE/FALSE;
1521 * 'contact_type' => $contactType;
1522 * 'rule' = $rule;
1523 * 'rule_group_id' => $ruleGroupID;
1524 * 'excludedContactIDs' => $excludedContactIDs;
1525 * @param array $dedupeResults
1526 * Array of results ['handled' => TRUE/FALSE, 'ids' => array of IDs of duplicate contacts]
1527 * @param array $contextParams
1528 * The context if relevant, eg. ['event_id' => X]
1529 *
1530 * @return mixed
1531 */
1532 public static function findDuplicates($dedupeParams, &$dedupeResults, $contextParams) {
1533 return self::singleton()
be2fb01f 1534 ->invoke(['dedupeParams', 'dedupeResults', 'contextParams'], $dedupeParams, $dedupeResults, $contextParams, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_findDuplicates');
b8cb7e46
MWMC
1535 }
1536
6a488035
TO
1537 /**
1538 * This hook is called AFTER EACH email has been processed by the script bin/EmailProcessor.php
1539 *
77855840
TO
1540 * @param string $type
1541 * Type of mail processed: 'activity' OR 'mailing'.
f4aaa82a 1542 * @param array &$params the params that were sent to the CiviCRM API function
77855840
TO
1543 * @param object $mail
1544 * The mail object which is an ezcMail class.
f4aaa82a 1545 * @param array &$result the result returned by the api call
77855840
TO
1546 * @param string $action
1547 * (optional ) the requested action to be performed if the types was 'mailing'.
6a488035 1548 *
f4aaa82a 1549 * @return mixed
6a488035 1550 */
00be9182 1551 public static function emailProcessor($type, &$params, $mail, &$result, $action = NULL) {
37cd2432 1552 return self::singleton()
be2fb01f 1553 ->invoke(['type', 'params', 'mail', 'result', 'action'], $type, $params, $mail, $result, $action, self::$_nullObject, 'civicrm_emailProcessor');
6a488035
TO
1554 }
1555
1556 /**
1557 * This hook is called after a row has been processed and the
1558 * record (and associated records imported
1559 *
77855840
TO
1560 * @param string $object
1561 * Object being imported (for now Contact only, later Contribution, Activity,.
9399901d 1562 * Participant and Member)
77855840
TO
1563 * @param string $usage
1564 * Hook usage/location (for now process only, later mapping and others).
1565 * @param string $objectRef
1566 * Import record object.
1567 * @param array $params
1568 * Array with various key values: currently.
6a488035
TO
1569 * contactID - contact id
1570 * importID - row id in temp table
1571 * importTempTable - name of tempTable
1572 * fieldHeaders - field headers
1573 * fields - import fields
1574 *
b8c71ffa 1575 * @return mixed
6a488035 1576 */
00be9182 1577 public static function import($object, $usage, &$objectRef, &$params) {
be2fb01f 1578 return self::singleton()->invoke(['object', 'usage', 'objectRef', 'params'], $object, $usage, $objectRef, $params,
87dab4a4 1579 self::$_nullObject, self::$_nullObject,
6a488035
TO
1580 'civicrm_import'
1581 );
1582 }
1583
1584 /**
1585 * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission()
aa5ba569 1586 * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/permissions.php).
6a488035 1587 *
77855840
TO
1588 * @param string $entity
1589 * The API entity (like contact).
1590 * @param string $action
1591 * The API action (like get).
f4aaa82a 1592 * @param array &$params the API parameters
c490a46a 1593 * @param array &$permissions the associative permissions array (probably to be altered by this hook)
f4aaa82a
EM
1594 *
1595 * @return mixed
6a488035 1596 */
00be9182 1597 public static function alterAPIPermissions($entity, $action, &$params, &$permissions) {
be2fb01f 1598 return self::singleton()->invoke(['entity', 'action', 'params', 'permissions'], $entity, $action, $params, $permissions,
87dab4a4 1599 self::$_nullObject, self::$_nullObject,
6a488035
TO
1600 'civicrm_alterAPIPermissions'
1601 );
1602 }
1603
5bc392e6 1604 /**
c490a46a 1605 * @param CRM_Core_DAO $dao
5bc392e6
EM
1606 *
1607 * @return mixed
1608 */
00be9182 1609 public static function postSave(&$dao) {
6a488035 1610 $hookName = 'civicrm_postSave_' . $dao->getTableName();
be2fb01f 1611 return self::singleton()->invoke(['dao'], $dao,
87dab4a4 1612 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1613 $hookName
1614 );
1615 }
1616
1617 /**
1618 * This hook allows user to customize context menu Actions on contact summary page.
1619 *
77855840
TO
1620 * @param array $actions
1621 * Array of all Actions in contextmenu.
1622 * @param int $contactID
1623 * ContactID for the summary page.
f4aaa82a
EM
1624 *
1625 * @return mixed
6a488035 1626 */
00be9182 1627 public static function summaryActions(&$actions, $contactID = NULL) {
be2fb01f 1628 return self::singleton()->invoke(['actions', 'contactID'], $actions, $contactID,
87dab4a4 1629 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1630 'civicrm_summaryActions'
1631 );
1632 }
1633
1634 /**
1635 * This hook is called from CRM_Core_Selector_Controller through which all searches in civicrm go.
1636 * This enables us hook implementors to modify both the headers and the rows
1637 *
1638 * The BIGGEST drawback with this hook is that you may need to modify the result template to include your
1639 * fields. The result files are CRM/{Contact,Contribute,Member,Event...}/Form/Selector.tpl
1640 *
1641 * However, if you use the same number of columns, you can overwrite the existing columns with the values that
1642 * you want displayed. This is a hackish, but avoids template modification.
1643 *
77855840
TO
1644 * @param string $objectName
1645 * The component name that we are doing the search.
6a488035 1646 * activity, campaign, case, contact, contribution, event, grant, membership, and pledge
f4aaa82a
EM
1647 * @param array &$headers the list of column headers, an associative array with keys: ( name, sort, order )
1648 * @param array &$rows the list of values, an associate array with fields that are displayed for that component
16b10e64
CW
1649 * @param array $selector
1650 * the selector object. Allows you access to the context of the search
6a488035 1651 *
b8c71ffa 1652 * @return mixed
50bfb460 1653 * modify the header and values object to pass the data you need
6a488035 1654 */
00be9182 1655 public static function searchColumns($objectName, &$headers, &$rows, &$selector) {
be2fb01f 1656 return self::singleton()->invoke(['objectName', 'headers', 'rows', 'selector'], $objectName, $headers, $rows, $selector,
87dab4a4 1657 self::$_nullObject, self::$_nullObject,
6a488035
TO
1658 'civicrm_searchColumns'
1659 );
1660 }
1661
1662 /**
1663 * This hook is called when uf groups are being built for a module.
1664 *
77855840
TO
1665 * @param string $moduleName
1666 * Module name.
1667 * @param array $ufGroups
1668 * Array of ufgroups for a module.
6a488035
TO
1669 *
1670 * @return null
6a488035 1671 */
00be9182 1672 public static function buildUFGroupsForModule($moduleName, &$ufGroups) {
be2fb01f 1673 return self::singleton()->invoke(['moduleName', 'ufGroups'], $moduleName, $ufGroups,
87dab4a4 1674 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1675 'civicrm_buildUFGroupsForModule'
1676 );
1677 }
1678
693067e3
TO
1679 /**
1680 * (EXPERIMENTAL) Scan extensions for a list of auto-registered interfaces.
1681 *
1682 * This hook is currently experimental. It is a means to implementing `mixin/scan-classes@1`.
1683 * If there are no major difficulties circa 5.55, then it can be marked stable.
1684 *
1685 * @param string[] $classes
1686 * List of classes which may be of interest to the class-scanner.
1687 */
1688 public static function scanClasses(array &$classes) {
1689 self::singleton()->invoke(['classes'], $classes, self::$_nullObject,
1690 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
1691 'civicrm_scanClasses'
1692 );
1693 }
1694
6a488035
TO
1695 /**
1696 * This hook is called when we are determining the contactID for a specific
1697 * email address
1698 *
77855840
TO
1699 * @param string $email
1700 * The email address.
1701 * @param int $contactID
1702 * The contactID that matches this email address, IF it exists.
1703 * @param array $result
1704 * (reference) has two fields.
6a488035
TO
1705 * contactID - the new (or same) contactID
1706 * action - 3 possible values:
9399901d
KJ
1707 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_CREATE_INDIVIDUAL - create a new contact record
1708 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_OVERRIDE - use the new contactID
1709 * CRM_Utils_Mail_Incoming::EMAILPROCESSOR_IGNORE - skip this email address
6a488035
TO
1710 *
1711 * @return null
6a488035 1712 */
00be9182 1713 public static function emailProcessorContact($email, $contactID, &$result) {
be2fb01f 1714 return self::singleton()->invoke(['email', 'contactID', 'result'], $email, $contactID, $result,
87dab4a4 1715 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1716 'civicrm_emailProcessorContact'
1717 );
1718 }
1719
1720 /**
fe482240 1721 * Hook definition for altering the generation of Mailing Labels.
6a488035 1722 *
77855840
TO
1723 * @param array $args
1724 * An array of the args in the order defined for the tcpdf multiCell api call.
6a488035
TO
1725 * with the variable names below converted into string keys (ie $w become 'w'
1726 * as the first key for $args)
1727 * float $w Width of cells. If 0, they extend up to the right margin of the page.
1728 * float $h Cell minimum height. The cell extends automatically if needed.
1729 * string $txt String to print
1730 * mixed $border Indicates if borders must be drawn around the cell block. The value can
1731 * be either a number:<ul><li>0: no border (default)</li><li>1: frame</li></ul>or
1732 * a string containing some or all of the following characters (in any order):
1733 * <ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
1734 * string $align Allows to center or align the text. Possible values are:<ul><li>L or empty string:
1735 * left align</li><li>C: center</li><li>R: right align</li><li>J: justification
1736 * (default value when $ishtml=false)</li></ul>
1737 * int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
1738 * int $ln Indicates where the current position should go after the call. Possible values are:<ul><li>0:
1739 * to the right</li><li>1: to the beginning of the next line [DEFAULT]</li><li>2: below</li></ul>
1740 * float $x x position in user units
1741 * float $y y position in user units
1742 * boolean $reseth if true reset the last cell height (default true).
b44e3f84 1743 * int $stretch stretch character mode: <ul><li>0 = disabled</li><li>1 = horizontal scaling only if
6a488035
TO
1744 * necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if
1745 * necessary</li><li>4 = forced character spacing</li></ul>
1746 * boolean $ishtml set to true if $txt is HTML content (default = false).
1747 * boolean $autopadding if true, uses internal padding and automatically adjust it to account for line width.
1748 * float $maxh maximum height. It should be >= $h and less then remaining space to the bottom of the page,
1749 * or 0 for disable this feature. This feature works only when $ishtml=false.
1750 *
f4aaa82a 1751 * @return mixed
6a488035 1752 */
00be9182 1753 public static function alterMailingLabelParams(&$args) {
be2fb01f 1754 return self::singleton()->invoke(['args'], $args,
6a488035 1755 self::$_nullObject, self::$_nullObject,
87dab4a4 1756 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1757 'civicrm_alterMailingLabelParams'
1758 );
1759 }
1760
1761 /**
fe482240 1762 * This hooks allows alteration of generated page content.
6a488035 1763 *
77855840
TO
1764 * @param $content
1765 * Previously generated content.
1766 * @param $context
1767 * Context of content - page or form.
1768 * @param $tplName
1769 * The file name of the tpl.
1770 * @param $object
1771 * A reference to the page or form object.
6a488035 1772 *
f4aaa82a 1773 * @return mixed
6a488035 1774 */
00be9182 1775 public static function alterContent(&$content, $context, $tplName, &$object) {
be2fb01f 1776 return self::singleton()->invoke(['content', 'context', 'tplName', 'object'], $content, $context, $tplName, $object,
87dab4a4 1777 self::$_nullObject, self::$_nullObject,
6a488035
TO
1778 'civicrm_alterContent'
1779 );
1780 }
1781
8aac22c8 1782 /**
1783 * This hooks allows alteration of the tpl file used to generate content. It differs from the
1784 * altercontent hook as the content has already been rendered through the tpl at that point
1785 *
77855840
TO
1786 * @param $formName
1787 * Previously generated content.
1788 * @param $form
1789 * Reference to the form object.
1790 * @param $context
1791 * Context of content - page or form.
1792 * @param $tplName
1793 * Reference the file name of the tpl.
8aac22c8 1794 *
f4aaa82a 1795 * @return mixed
8aac22c8 1796 */
00be9182 1797 public static function alterTemplateFile($formName, &$form, $context, &$tplName) {
be2fb01f 1798 return self::singleton()->invoke(['formName', 'form', 'context', 'tplName'], $formName, $form, $context, $tplName,
87dab4a4 1799 self::$_nullObject, self::$_nullObject,
8aac22c8 1800 'civicrm_alterTemplateFile'
1801 );
1802 }
f4aaa82a 1803
281eacd8 1804 /**
4228925b 1805 * Register cryptographic resources, such as keys and cipher-suites.
281eacd8 1806 *
4228925b
TO
1807 * Ex: $crypto->addSymmetricKey([
1808 * 'key' => hash_hkdf('sha256', 'abcd1234'),
1809 * 'suite' => 'aes-cbc-hs',
1810 * ]);
281eacd8
TO
1811 *
1812 * @param \Civi\Crypto\CryptoRegistry $crypto
1813 *
1814 * @return mixed
1815 */
1816 public static function crypto($crypto) {
1817 return self::singleton()->invoke(['crypto'], $crypto, self::$_nullObject,
1818 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1819 self::$_nullObject,
1820 'civicrm_crypto'
1821 );
1822 }
1823
6a488035 1824 /**
fe482240 1825 * This hook collects the trigger definition from all components.
6a488035 1826 *
f4aaa82a 1827 * @param $info
77855840
TO
1828 * @param string $tableName
1829 * (optional) the name of the table that we are interested in only.
f4aaa82a
EM
1830 *
1831 * @internal param \reference $triggerInfo to an array of trigger information
6a488035
TO
1832 * each element has 4 fields:
1833 * table - array of tableName
1834 * when - BEFORE or AFTER
1835 * event - array of eventName - INSERT OR UPDATE OR DELETE
1836 * sql - array of statements optionally terminated with a ;
1837 * a statement can use the tokes {tableName} and {eventName}
1838 * to do token replacement with the table / event. This allows
1839 * templatizing logging and other hooks
f4aaa82a 1840 * @return mixed
6a488035 1841 */
00be9182 1842 public static function triggerInfo(&$info, $tableName = NULL) {
be2fb01f 1843 return self::singleton()->invoke(['info', 'tableName'], $info, $tableName,
87dab4a4 1844 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
1845 self::$_nullObject,
1846 'civicrm_triggerInfo'
1847 );
1848 }
6714d8d2 1849
fd1ea018
TO
1850 /**
1851 * Define the list of fields supported in APIv4 data-translation.
1852 *
1853 * @param array $fields
1854 * List of data fields to translate, organized by table and column.
1855 * Omitted/unlisted fields are not translated. Any listed field may be translated.
f28ee435 1856 * Values should be TRUE.
fd1ea018 1857 * Ex: $fields['civicrm_event']['summary'] = TRUE
f28ee435 1858 * @return mixed
fd1ea018
TO
1859 */
1860 public static function translateFields(&$fields) {
1861 return self::singleton()->invoke(['fields'], $fields, self::$_nullObject,
1862 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1863 self::$_nullObject,
1864 'civicrm_translateFields'
1865 );
1866 }
1867
ef587f9c 1868 /**
1869 * This hook allows changes to the spec of which tables to log.
1870 *
1871 * @param array $logTableSpec
1872 *
1873 * @return mixed
1874 */
1875 public static function alterLogTables(&$logTableSpec) {
be2fb01f 1876 return self::singleton()->invoke(['logTableSpec'], $logTableSpec, $_nullObject,
ef587f9c 1877 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1878 self::$_nullObject,
1879 'civicrm_alterLogTables'
1880 );
1881 }
6a488035
TO
1882
1883 /**
1df69f8f
TO
1884 * Run early installation steps for an extension. Ex: Create new MySQL table.
1885 *
1886 * This dispatches directly to each new extension. You will only receive notices for your own installation.
1887 *
1888 * If multiple extensions are installed simultaneously, they will all run
1889 * `hook_install`/`hook_enable` back-to-back (in order of dependency).
1890 *
1891 * This runs BEFORE refreshing major caches and services (such as
1892 * `ManagedEntities` and `CRM_Logging_Schema`).
1893 *
1894 * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_install
6a488035 1895 */
00be9182 1896 public static function install() {
41344661
TO
1897 // Actually invoke via CRM_Extension_Manager_Module::callHook
1898 throw new \RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__, __FUNCTION__));
6a488035
TO
1899 }
1900
1df69f8f
TO
1901 /**
1902 * Run later installation steps. Ex: Call a bespoke API-job for the first time.
1903 *
1904 * This dispatches directly to each new extension. You will only receive notices for your own installation.
1905 *
1906 * If multiple extensions are installed simultaneously, they will all run
1907 * `hook_postInstall` back-to-back (in order of dependency).
1908 *
1909 * This runs AFTER refreshing major caches and services (such as
1910 * `ManagedEntities` and `CRM_Logging_Schema`).
1911 *
1912 * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall
1913 */
1914 public static function postInstall() {
1915 // Actually invoke via CRM_Extension_Manager_Module::callHook
1916 throw new \RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__, __FUNCTION__));
1917 }
1918
6a488035
TO
1919 /**
1920 * This hook is called when a module-extension is uninstalled.
9399901d
KJ
1921 * Each module will receive hook_civicrm_uninstall during its own uninstallation (but not during the
1922 * uninstallation of unrelated modules).
6a488035 1923 */
00be9182 1924 public static function uninstall() {
41344661
TO
1925 // Actually invoke via CRM_Extension_Manager_Module::callHook
1926 throw new \RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__, __FUNCTION__));
6a488035
TO
1927 }
1928
1929 /**
1930 * This hook is called when a module-extension is re-enabled.
9399901d
KJ
1931 * Each module will receive hook_civicrm_enable during its own re-enablement (but not during the
1932 * re-enablement of unrelated modules).
6a488035 1933 */
00be9182 1934 public static function enable() {
41344661
TO
1935 // Actually invoke via CRM_Extension_Manager_Module::callHook
1936 throw new \RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__, __FUNCTION__));
6a488035
TO
1937 }
1938
1939 /**
1940 * This hook is called when a module-extension is disabled.
9399901d
KJ
1941 * Each module will receive hook_civicrm_disable during its own disablement (but not during the
1942 * disablement of unrelated modules).
6a488035 1943 */
00be9182 1944 public static function disable() {
41344661
TO
1945 // Actually invoke via CRM_Extension_Manager_Module::callHook
1946 throw new \RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__, __FUNCTION__));
6a488035
TO
1947 }
1948
f9bdf062 1949 /**
1950 * Alter redirect.
1951 *
1952 * This hook is called when the browser is being re-directed and allows the url
1953 * to be altered.
1954 *
1955 * @param \Psr\Http\Message\UriInterface $url
1956 * @param array $context
1957 * Additional information about context
1958 * - output - if this is 'json' then it will return json.
1959 *
1960 * @return null
1961 * the return value is ignored
1962 */
ca4ce861 1963 public static function alterRedirect(&$url, &$context) {
be2fb01f 1964 return self::singleton()->invoke(['url', 'context'], $url,
f9bdf062 1965 $context, self::$_nullObject,
1966 self::$_nullObject, self::$_nullObject, self::$_nullObject,
1967 'civicrm_alterRedirect'
1968 );
1969 }
1970
5bc392e6
EM
1971 /**
1972 * @param $varType
1973 * @param $var
1974 * @param $object
1975 *
1976 * @return mixed
1977 */
00be9182 1978 public static function alterReportVar($varType, &$var, &$object) {
be2fb01f 1979 return self::singleton()->invoke(['varType', 'var', 'object'], $varType, $var, $object,
6a488035 1980 self::$_nullObject,
87dab4a4 1981 self::$_nullObject, self::$_nullObject,
6a488035
TO
1982 'civicrm_alterReportVar'
1983 );
1984 }
1985
1986 /**
1987 * This hook is called to drive database upgrades for extension-modules.
1988 *
72536736
AH
1989 * @param string $op
1990 * The type of operation being performed; 'check' or 'enqueue'.
1991 * @param CRM_Queue_Queue $queue
1992 * (for 'enqueue') the modifiable list of pending up upgrade tasks.
6a488035 1993 *
72536736
AH
1994 * @return bool|null
1995 * NULL, if $op is 'enqueue'.
1996 * TRUE, if $op is 'check' and upgrades are pending.
1997 * FALSE, if $op is 'check' and upgrades are not pending.
6a488035 1998 */
00be9182 1999 public static function upgrade($op, CRM_Queue_Queue $queue = NULL) {
be2fb01f 2000 return self::singleton()->invoke(['op', 'queue'], $op, $queue,
87dab4a4 2001 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
2002 self::$_nullObject,
2003 'civicrm_upgrade'
2004 );
2005 }
2006
2007 /**
2008 * This hook is called when an email has been successfully sent by CiviCRM, but not on an error.
2009 *
72536736
AH
2010 * @param array $params
2011 * The mailing parameters. Array fields include: groupName, from, toName,
2012 * toEmail, subject, cc, bcc, text, html, returnPath, replyTo, headers,
2013 * attachments (array)
2014 *
2015 * @return mixed
6a488035 2016 */
0870a69e 2017 public static function postEmailSend(&$params) {
be2fb01f 2018 return self::singleton()->invoke(['params'], $params,
6a488035 2019 self::$_nullObject, self::$_nullObject,
0870a69e 2020 self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
2021 'civicrm_postEmailSend'
2022 );
2023 }
2024
0870a69e
BS
2025 /**
2026 * This hook is called when a CiviMail mailing has completed
2027 *
c9a3cf8c
BS
2028 * @param int $mailingId
2029 * Mailing ID
0870a69e
BS
2030 *
2031 * @return mixed
2032 */
c9a3cf8c 2033 public static function postMailing($mailingId) {
be2fb01f 2034 return self::singleton()->invoke(['mailingId'], $mailingId,
0870a69e
BS
2035 self::$_nullObject, self::$_nullObject,
2036 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2037 'civicrm_postMailing'
2038 );
2039 }
2040
6a488035 2041 /**
fe482240 2042 * This hook is called when Settings specifications are loaded.
6a488035 2043 *
72536736
AH
2044 * @param array $settingsFolders
2045 * List of paths from which to derive metadata
2046 *
2047 * @return mixed
6a488035 2048 */
00be9182 2049 public static function alterSettingsFolders(&$settingsFolders) {
be2fb01f 2050 return self::singleton()->invoke(['settingsFolders'], $settingsFolders,
37cd2432
TO
2051 self::$_nullObject, self::$_nullObject,
2052 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2053 'civicrm_alterSettingsFolders'
6a488035
TO
2054 );
2055 }
2056
2057 /**
2058 * This hook is called when Settings have been loaded from the xml
2059 * It is an opportunity for hooks to alter the data
2060 *
77855840
TO
2061 * @param array $settingsMetaData
2062 * Settings Metadata.
72536736
AH
2063 * @param int $domainID
2064 * @param mixed $profile
2065 *
2066 * @return mixed
6a488035 2067 */
00be9182 2068 public static function alterSettingsMetaData(&$settingsMetaData, $domainID, $profile) {
be2fb01f 2069 return self::singleton()->invoke(['settingsMetaData', 'domainID', 'profile'], $settingsMetaData,
37cd2432
TO
2070 $domainID, $profile,
2071 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2072 'civicrm_alterSettingsMetaData'
6a488035
TO
2073 );
2074 }
2075
5270c026
XD
2076 /**
2077 * This hook is called before running an api call.
2078 *
72536736
AH
2079 * @param API_Wrapper[] $wrappers
2080 * (see CRM_Utils_API_ReloadOption as an example)
2081 * @param mixed $apiRequest
5270c026 2082 *
72536736
AH
2083 * @return null
2084 * The return value is ignored
5270c026 2085 */
00be9182 2086 public static function apiWrappers(&$wrappers, $apiRequest) {
09f8c8dc 2087 return self::singleton()
be2fb01f 2088 ->invoke(['wrappers', 'apiRequest'], $wrappers, $apiRequest, self::$_nullObject, self::$_nullObject, self::$_nullObject,
37cd2432
TO
2089 self::$_nullObject, 'civicrm_apiWrappers'
2090 );
5270c026
XD
2091 }
2092
6a488035
TO
2093 /**
2094 * This hook is called before running pending cron jobs.
2095 *
2096 * @param CRM_Core_JobManager $jobManager
2097 *
72536736
AH
2098 * @return null
2099 * The return value is ignored.
6a488035 2100 */
00be9182 2101 public static function cron($jobManager) {
be2fb01f 2102 return self::singleton()->invoke(['jobManager'],
87dab4a4 2103 $jobManager, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
2104 'civicrm_cron'
2105 );
2106 }
2107
2108 /**
29541977 2109 * This hook is called when exporting Civi's permission to the CMS. Use this hook to modify
6a488035
TO
2110 * the array of system permissions for CiviCRM.
2111 *
ea54c6e5 2112 * @param array $newPermissions
2113 * Array to be filled with permissions.
6a488035 2114 *
72536736
AH
2115 * @return null
2116 * The return value is ignored
6a488035 2117 */
34f47692
YN
2118 public static function permission(&$newPermissions) {
2119 return self::singleton()->invoke(['permissions'], $newPermissions, self::$_nullObject,
ea54c6e5 2120 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
6a488035
TO
2121 'civicrm_permission'
2122 );
2123 }
fed67e4d 2124
29541977
TO
2125 /**
2126 * This hook is used to enumerate the list of available permissions. It may
2127 * include concrete permissions defined by Civi, concrete permissions defined
2128 * by the CMS, and/or synthetic permissions.
2129 *
2130 * @param array $permissions
2131 * Array of permissions, keyed by symbolic name. Each is an array with fields:
2132 * - group: string (ex: "civicrm", "cms")
2133 * - title: string (ex: "CiviEvent: Register for events")
2134 * - description: string (ex: "Register for events online")
2135 * - is_synthetic: bool (TRUE for synthetic permissions with a bespoke evaluation. FALSE for concrete permissions that registered+granted in the UF user-management layer.
2136 * Default TRUE iff name begins with '@')
2137 * - is_active: bool (TRUE if this permission is defined by. Default: TRUE)
2138 *
2139 * @return null
2140 * The return value is ignored
2141 * @see Civi\Api4\Permission::get()
2142 */
2143 public static function permissionList(&$permissions) {
2144 return self::singleton()->invoke(['permissions'], $permissions,
2145 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2146 'civicrm_permissionList'
2147 );
2148 }
2149
3ae62cab
NG
2150 /**
2151 * This hook is called when checking permissions; use this hook to dynamically
2152 * escalate user permissions in certain use cases (cf. CRM-19256).
2153 *
2154 * @param string $permission
2155 * The name of an atomic permission, ie. 'access deleted contacts'
68773b26 2156 * @param bool $granted
3ae62cab 2157 * Whether this permission is currently granted. The hook can change this value.
fa4dac9c
CW
2158 * @param int $contactId
2159 * Contact whose permissions we are checking (if null, assume current user).
3ae62cab
NG
2160 *
2161 * @return null
2162 * The return value is ignored
2163 */
fa4dac9c 2164 public static function permission_check($permission, &$granted, $contactId) {
be2fb01f 2165 return self::singleton()->invoke(['permission', 'granted', 'contactId'], $permission, $granted, $contactId,
fa4dac9c 2166 self::$_nullObject, self::$_nullObject, self::$_nullObject,
3ae62cab
NG
2167 'civicrm_permission_check'
2168 );
2169 }
2170
b124f74b
TO
2171 /**
2172 * Rotate the cryptographic key used in the database.
2173 *
2174 * The purpose of this hook is to visit any encrypted values in the database
2175 * and re-encrypt the content.
2176 *
2177 * For values encoded via `CryptoToken`, you can use `CryptoToken::rekey($oldToken, $tag)`
2178 *
2179 * @param string $tag
2180 * The type of crypto-key that is currently being rotated.
2181 * The hook-implementer should use this to decide which (if any) fields to visit.
2182 * Ex: 'CRED'
2183 * @param \Psr\Log\LoggerInterface $log
2184 * List of messages about re-keyed values.
2185 *
2186 * @code
2187 * function example_civicrm_rekey($tag, &$log) {
2188 * if ($tag !== 'CRED') return;
2189 *
2190 * $cryptoToken = Civi::service('crypto.token');
2191 * $rows = sql('SELECT id, secret_column FROM some_table');
2192 * foreach ($rows as $row) {
2193 * $new = $cryptoToken->rekey($row['secret_column']);
2194 * if ($new !== NULL) {
2195 * sql('UPDATE some_table SET secret_column = %1 WHERE id = %2',
2196 * $new, $row['id']);
2197 * }
2198 * }
2199 * }
2200 * @endCode
2201 *
2202 * @return null
2203 * The return value is ignored
2204 */
2205 public static function cryptoRotateKey($tag, $log) {
2206 return self::singleton()->invoke(['tag', 'log'], $tag, $log, self::$_nullObject,
2207 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2208 'civicrm_cryptoRotateKey'
2209 );
2210 }
2211
4b57bc9f 2212 /**
e97c66ff 2213 * @param CRM_Core_Exception $exception
77855840
TO
2214 * @param mixed $request
2215 * Reserved for future use.
4b57bc9f 2216 */
37cd2432 2217 public static function unhandledException($exception, $request = NULL) {
4caeca04 2218 $event = new \Civi\Core\Event\UnhandledExceptionEvent($exception, self::$_nullObject);
c73e3098 2219 \Civi::dispatcher()->dispatch('hook_civicrm_unhandled_exception', $event);
4b57bc9f 2220 }
fed67e4d
TO
2221
2222 /**
fe482240 2223 * This hook is called for declaring managed entities via API.
fed67e4d 2224 *
e97c66ff 2225 * Note: This is a pre-boot hook. It will dispatch via the extension/module
4d8e83b6
TO
2226 * subsystem but *not* the Symfony EventDispatcher.
2227 *
72536736
AH
2228 * @param array[] $entityTypes
2229 * List of entity types; each entity-type is an array with keys:
fed67e4d
TO
2230 * - name: string, a unique short name (e.g. "ReportInstance")
2231 * - class: string, a PHP DAO class (e.g. "CRM_Report_DAO_Instance")
2232 * - table: string, a SQL table name (e.g. "civicrm_report_instance")
740dd877
TO
2233 * - fields_callback: array, list of callables which manipulates field list
2234 * - links_callback: array, list of callables which manipulates fk list
fed67e4d 2235 *
72536736
AH
2236 * @return null
2237 * The return value is ignored
fed67e4d 2238 */
00be9182 2239 public static function entityTypes(&$entityTypes) {
be2fb01f 2240 return self::singleton()->invoke(['entityTypes'], $entityTypes, self::$_nullObject, self::$_nullObject,
87dab4a4 2241 self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_entityTypes'
fed67e4d
TO
2242 );
2243 }
a8387f19 2244
bdd65b5c
TO
2245 /**
2246 * Build a description of available hooks.
2247 *
ec84755a 2248 * @param \Civi\Core\CiviEventInspector $inspector
bdd65b5c 2249 */
47e7c2f8 2250 public static function eventDefs($inspector) {
be2fb01f 2251 $event = \Civi\Core\Event\GenericHookEvent::create([
00932067 2252 'inspector' => $inspector,
be2fb01f 2253 ]);
47e7c2f8 2254 Civi::dispatcher()->dispatch('hook_civicrm_eventDefs', $event);
bdd65b5c
TO
2255 }
2256
a8387f19 2257 /**
fe482240 2258 * This hook is called while preparing a profile form.
a8387f19 2259 *
0fcad357 2260 * @param string $profileName
72536736 2261 * @return mixed
a8387f19 2262 */
0fcad357 2263 public static function buildProfile($profileName) {
be2fb01f 2264 return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject,
87dab4a4 2265 self::$_nullObject, self::$_nullObject, 'civicrm_buildProfile');
a8387f19
TO
2266 }
2267
2268 /**
fe482240 2269 * This hook is called while validating a profile form submission.
a8387f19 2270 *
0fcad357 2271 * @param string $profileName
72536736 2272 * @return mixed
a8387f19 2273 */
0fcad357 2274 public static function validateProfile($profileName) {
be2fb01f 2275 return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject,
87dab4a4 2276 self::$_nullObject, self::$_nullObject, 'civicrm_validateProfile');
a8387f19
TO
2277 }
2278
2279 /**
fe482240 2280 * This hook is called processing a valid profile form submission.
a8387f19 2281 *
0fcad357 2282 * @param string $profileName
72536736 2283 * @return mixed
a8387f19 2284 */
0fcad357 2285 public static function processProfile($profileName) {
be2fb01f 2286 return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject,
87dab4a4 2287 self::$_nullObject, self::$_nullObject, 'civicrm_processProfile');
a8387f19
TO
2288 }
2289
2290 /**
2291 * This hook is called while preparing a read-only profile screen
2292 *
0fcad357 2293 * @param string $profileName
72536736 2294 * @return mixed
a8387f19 2295 */
0fcad357 2296 public static function viewProfile($profileName) {
be2fb01f 2297 return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject,
87dab4a4 2298 self::$_nullObject, self::$_nullObject, 'civicrm_viewProfile');
a8387f19
TO
2299 }
2300
2301 /**
2302 * This hook is called while preparing a list of contacts (based on a profile)
2303 *
0fcad357 2304 * @param string $profileName
72536736 2305 * @return mixed
a8387f19 2306 */
0fcad357 2307 public static function searchProfile($profileName) {
be2fb01f 2308 return self::singleton()->invoke(['profileName'], $profileName, self::$_nullObject, self::$_nullObject, self::$_nullObject,
87dab4a4 2309 self::$_nullObject, self::$_nullObject, 'civicrm_searchProfile');
9399901d
KJ
2310 }
2311
d0fc33e2
M
2312 /**
2313 * This hook is invoked when building a CiviCRM name badge.
2314 *
77855840
TO
2315 * @param string $labelName
2316 * String referencing name of badge format.
2317 * @param object $label
2318 * Reference to the label object.
2319 * @param array $format
2320 * Array of format data.
2321 * @param array $participant
2322 * Array of participant values.
d0fc33e2 2323 *
a6c01b45
CW
2324 * @return null
2325 * the return value is ignored
d0fc33e2 2326 */
00be9182 2327 public static function alterBadge($labelName, &$label, &$format, &$participant) {
37cd2432 2328 return self::singleton()
be2fb01f 2329 ->invoke(['labelName', 'label', 'format', 'participant'], $labelName, $label, $format, $participant, self::$_nullObject, self::$_nullObject, 'civicrm_alterBadge');
d0fc33e2
M
2330 }
2331
9399901d 2332 /**
fe482240 2333 * This hook is called before encoding data in barcode.
9399901d 2334 *
77855840
TO
2335 * @param array $data
2336 * Associated array of values available for encoding.
2337 * @param string $type
2338 * Type of barcode, classic barcode or QRcode.
2339 * @param string $context
2340 * Where this hooks is invoked.
9399901d 2341 *
72536736 2342 * @return mixed
9399901d 2343 */
e7292422 2344 public static function alterBarcode(&$data, $type = 'barcode', $context = 'name_badge') {
be2fb01f 2345 return self::singleton()->invoke(['data', 'type', 'context'], $data, $type, $context, self::$_nullObject,
87dab4a4 2346 self::$_nullObject, self::$_nullObject, 'civicrm_alterBarcode');
a8387f19 2347 }
99e9587a 2348
72ad6c1b
TO
2349 /**
2350 * Modify or replace the Mailer object used for outgoing mail.
2351 *
2352 * @param object $mailer
2353 * The default mailer produced by normal configuration; a PEAR "Mail" class (like those returned by Mail::factory)
2354 * @param string $driver
2355 * The type of the default mailer (eg "smtp", "sendmail", "mock", "CRM_Mailing_BAO_Spool")
2356 * @param array $params
2357 * The default mailer config options
72536736
AH
2358 *
2359 * @return mixed
72ad6c1b
TO
2360 * @see Mail::factory
2361 */
f2b63bd3 2362 public static function alterMailer(&$mailer, $driver, $params) {
c8e4bea0 2363 return self::singleton()
be2fb01f 2364 ->invoke(['mailer', 'driver', 'params'], $mailer, $driver, $params, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_alterMailer');
72ad6c1b
TO
2365 }
2366
99e9587a 2367 /**
2efcf0c2 2368 * This hook is called while building the core search query,
99e9587a
DS
2369 * so hook implementers can provide their own query objects which alters/extends core search.
2370 *
72536736
AH
2371 * @param array $queryObjects
2372 * @param string $type
2373 *
2374 * @return mixed
99e9587a 2375 */
00be9182 2376 public static function queryObjects(&$queryObjects, $type = 'Contact') {
37cd2432 2377 return self::singleton()
be2fb01f 2378 ->invoke(['queryObjects', 'type'], $queryObjects, $type, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_queryObjects');
99e9587a 2379 }
15d9b3ae
N
2380
2381 /**
f263929f 2382 * This hook is called while initializing the default dashlets for a contact dashboard.
15d9b3ae 2383 *
72536736
AH
2384 * @param array $availableDashlets
2385 * List of dashlets; each is formatted per api/v3/Dashboard
2386 * @param array $defaultDashlets
2387 * List of dashlets; each is formatted per api/v3/DashboardContact
2388 *
2389 * @return mixed
15d9b3ae 2390 */
00be9182 2391 public static function dashboard_defaults($availableDashlets, &$defaultDashlets) {
37cd2432 2392 return self::singleton()
be2fb01f 2393 ->invoke(['availableDashlets', 'defaultDashlets'], $availableDashlets, $defaultDashlets, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_dashboard_defaults');
15d9b3ae 2394 }
02094cdb
JJ
2395
2396 /**
2397 * This hook is called before a case merge (or a case reassign)
f4aaa82a 2398 *
77855840
TO
2399 * @param int $mainContactId
2400 * @param int $mainCaseId
2401 * @param int $otherContactId
2402 * @param int $otherCaseId
3d0d359e 2403 * @param bool $changeClient
f4aaa82a 2404 *
b8c71ffa 2405 * @return mixed
02094cdb 2406 */
00be9182 2407 public static function pre_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
37cd2432 2408 return self::singleton()
be2fb01f 2409 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self::$_nullObject, 'civicrm_pre_case_merge');
02094cdb 2410 }
f4aaa82a 2411
02094cdb
JJ
2412 /**
2413 * This hook is called after a case merge (or a case reassign)
f4aaa82a 2414 *
77855840
TO
2415 * @param int $mainContactId
2416 * @param int $mainCaseId
2417 * @param int $otherContactId
2418 * @param int $otherCaseId
3d0d359e 2419 * @param bool $changeClient
77b97be7 2420 *
b8c71ffa 2421 * @return mixed
02094cdb 2422 */
00be9182 2423 public static function post_case_merge($mainContactId, $mainCaseId = NULL, $otherContactId = NULL, $otherCaseId = NULL, $changeClient = FALSE) {
37cd2432 2424 return self::singleton()
be2fb01f 2425 ->invoke(['mainContactId', 'mainCaseId', 'otherContactId', 'otherCaseId', 'changeClient'], $mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient, self::$_nullObject, 'civicrm_post_case_merge');
02094cdb 2426 }
250b3b1f 2427
2428 /**
2429 * Issue CRM-14276
2430 * Add a hook for altering the display name
2431 *
6ced0172 2432 * hook_civicrm_contact_get_displayname(&$display_name, $contactId, $dao)
f4aaa82a 2433 *
250b3b1f 2434 * @param string $displayName
2435 * @param int $contactId
6ced0172
MW
2436 * @param CRM_Core_DAO $dao
2437 * A DAO object containing contact fields + primary email field as "email".
f4aaa82a
EM
2438 *
2439 * @return mixed
250b3b1f 2440 */
267578ea 2441 public static function alterDisplayName(&$displayName, $contactId, $dao) {
be2fb01f 2442 return self::singleton()->invoke(['displayName', 'contactId', 'dao'],
250b3b1f 2443 $displayName, $contactId, $dao, self::$_nullObject, self::$_nullObject,
2444 self::$_nullObject, 'civicrm_contact_get_displayname'
2445 );
2446 }
e7ff7042 2447
898951c6
TO
2448 /**
2449 * Modify the CRM_Core_Resources settings data.
2450 *
2451 * @param array $data
2452 * @see CRM_Core_Resources::addSetting
2453 */
2454 public static function alterResourceSettings(&$data) {
be2fb01f 2455 $event = \Civi\Core\Event\GenericHookEvent::create([
898951c6 2456 'data' => &$data,
be2fb01f 2457 ]);
898951c6
TO
2458 Civi::dispatcher()->dispatch('hook_civicrm_alterResourceSettings', $event);
2459 }
2460
e7ff7042
TO
2461 /**
2462 * EXPERIMENTAL: This hook allows one to register additional Angular modules
2463 *
77855840 2464 * @param array $angularModules
5438399c
TO
2465 * List of modules. Each module defines:
2466 * - ext: string, the CiviCRM extension which hosts the files.
2467 * - js: array, list of JS files or globs.
2468 * - css: array, list of CSS files or globs.
2469 * - partials: array, list of base-dirs containing HTML.
90c62ad3
TO
2470 * - partialsCallback: mixed, a callback function which generates a list of HTML
2471 * function(string $moduleName, array $moduleDefn) => array(string $file => string $html)
2472 * For future-proofing, use a serializable callback (e.g. string/array).
2473 * See also: Civi\Core\Resolver.
5438399c 2474 * - requires: array, list of required Angular modules.
79695663 2475 * - basePages: array, unconditionally load this module onto the given Angular pages. [v4.7.21+]
8da6c9b8
TO
2476 * If omitted, default to "array('civicrm/a')" for backward compat.
2477 * For a utility that should only be loaded on-demand, use "array()".
2478 * For a utility that should be loaded in all pages use, "array('*')".
e7ff7042 2479 *
0b882a86 2480 * ```
e7ff7042 2481 * function mymod_civicrm_angularModules(&$angularModules) {
8671b4f2
TO
2482 * $angularModules['myAngularModule'] = array(
2483 * 'ext' => 'org.example.mymod',
2484 * 'js' => array('js/myAngularModule.js'),
2485 * );
2486 * $angularModules['myBigAngularModule'] = array(
2487 * 'ext' => 'org.example.mymod',
e5c376e7
TO
2488 * 'js' => array('js/part1.js', 'js/part2.js', 'ext://other.ext.name/file.js', 'assetBuilder://dynamicAsset.js'),
2489 * 'css' => array('css/myAngularModule.css', 'ext://other.ext.name/file.css', 'assetBuilder://dynamicAsset.css'),
8671b4f2 2490 * 'partials' => array('partials/myBigAngularModule'),
5438399c 2491 * 'requires' => array('otherModuleA', 'otherModuleB'),
8da6c9b8 2492 * 'basePages' => array('civicrm/a'),
8671b4f2 2493 * );
e7ff7042 2494 * }
0b882a86
CW
2495 * ```
2496 *
2497 * @return null
2498 * the return value is ignored
e7ff7042 2499 */
00be9182 2500 public static function angularModules(&$angularModules) {
be2fb01f 2501 return self::singleton()->invoke(['angularModules'], $angularModules,
e7ff7042
TO
2502 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2503 'civicrm_angularModules'
2504 );
2505 }
2506
6dc348de
TO
2507 /**
2508 * Alter the definition of some Angular HTML partials.
2509 *
2510 * @param \Civi\Angular\Manager $angular
2511 *
0b882a86 2512 * ```
6dc348de 2513 * function example_civicrm_alterAngular($angular) {
f895c70e 2514 * $changeSet = \Civi\Angular\ChangeSet::create('mychanges')
6dc348de
TO
2515 * ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(phpQueryObject $doc) {
2516 * $doc->find('[ng-form="crmMailingSubform"]')->attr('cat-stevens', 'ts(\'wild world\')');
2517 * })
2518 * );
36bd3f7f 2519 * $angular->add($changeSet);
6dc348de 2520 * }
0b882a86 2521 * ```
6dc348de
TO
2522 */
2523 public static function alterAngular($angular) {
be2fb01f 2524 $event = \Civi\Core\Event\GenericHookEvent::create([
6dc348de 2525 'angular' => $angular,
be2fb01f 2526 ]);
6dc348de
TO
2527 Civi::dispatcher()->dispatch('hook_civicrm_alterAngular', $event);
2528 }
2529
c4560ed2
CW
2530 /**
2531 * This hook is called when building a link to a semi-static asset.
2532 *
2533 * @param string $asset
2534 * The name of the asset.
2535 * Ex: 'angular.json'
2536 * @param array $params
2537 * List of optional arguments which influence the content.
2538 * @return null
2539 * the return value is ignored
2540 */
2541 public static function getAssetUrl(&$asset, &$params) {
2542 return self::singleton()->invoke(['asset', 'params'],
2543 $asset, $params, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2544 'civicrm_getAssetUrl'
2545 );
2546 }
2547
87e3fe24
TO
2548 /**
2549 * This hook is called whenever the system builds a new copy of
2550 * semi-static asset.
2551 *
2552 * @param string $asset
2553 * The name of the asset.
2554 * Ex: 'angular.json'
2555 * @param array $params
2556 * List of optional arguments which influence the content.
2557 * Note: Params are immutable because they are part of the cache-key.
2558 * @param string $mimeType
2559 * Initially, NULL. Modify to specify the mime-type.
2560 * @param string $content
2561 * Initially, NULL. Modify to specify the rendered content.
2562 * @return null
2563 * the return value is ignored
2564 */
2565 public static function buildAsset($asset, $params, &$mimeType, &$content) {
be2fb01f 2566 return self::singleton()->invoke(['asset', 'params', 'mimeType', 'content'],
87e3fe24
TO
2567 $asset, $params, $mimeType, $content, self::$_nullObject, self::$_nullObject,
2568 'civicrm_buildAsset'
2569 );
2570 }
2571
708d8fa2
TO
2572 /**
2573 * This hook fires whenever a record in a case changes.
2574 *
2575 * @param \Civi\CCase\Analyzer $analyzer
542441f4 2576 * A bundle of data about the case (such as the case and activity records).
708d8fa2 2577 */
00be9182 2578 public static function caseChange(\Civi\CCase\Analyzer $analyzer) {
708d8fa2 2579 $event = new \Civi\CCase\Event\CaseChangeEvent($analyzer);
c73e3098 2580 \Civi::dispatcher()->dispatch('hook_civicrm_caseChange', $event);
708d8fa2 2581 }
688ad538 2582
40787e18
TO
2583 /**
2584 * Modify the CiviCRM container - add new services, parameters, extensions, etc.
2585 *
0b882a86 2586 * ```
40787e18
TO
2587 * use Symfony\Component\Config\Resource\FileResource;
2588 * use Symfony\Component\DependencyInjection\Definition;
2589 *
2590 * function mymodule_civicrm_container($container) {
2591 * $container->addResource(new FileResource(__FILE__));
2592 * $container->setDefinition('mysvc', new Definition('My\Class', array()));
2593 * }
0b882a86 2594 * ```
40787e18
TO
2595 *
2596 * Tip: The container configuration will be compiled/cached. The default cache
2597 * behavior is aggressive. When you first implement the hook, be sure to
2598 * flush the cache. Additionally, you should relax caching during development.
2599 * In `civicrm.settings.php`, set define('CIVICRM_CONTAINER_CACHE', 'auto').
2600 *
4d8e83b6
TO
2601 * Note: This is a preboot hook. It will dispatch via the extension/module
2602 * subsystem but *not* the Symfony EventDispatcher.
2603 *
40787e18
TO
2604 * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
2605 * @see http://symfony.com/doc/current/components/dependency_injection/index.html
2606 */
2607 public static function container(\Symfony\Component\DependencyInjection\ContainerBuilder $container) {
be2fb01f 2608 self::singleton()->invoke(['container'], $container, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_container');
40787e18
TO
2609 }
2610
6cccc6d4 2611 /**
6714d8d2 2612 * @param array $fileSearches CRM_Core_FileSearchInterface
6cccc6d4
TO
2613 * @return mixed
2614 */
00be9182 2615 public static function fileSearches(&$fileSearches) {
be2fb01f 2616 return self::singleton()->invoke(['fileSearches'], $fileSearches,
6cccc6d4
TO
2617 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2618 'civicrm_fileSearches'
2619 );
2620 }
96025800 2621
260e353b
TO
2622 /**
2623 * Check system status.
2624 *
675e2573
CW
2625 * @param CRM_Utils_Check_Message[] $messages
2626 * A list of messages regarding system status
2627 * @param array $statusNames
2628 * If specified, only these checks are being requested and others should be skipped
2629 * @param bool $includeDisabled
2630 * Run checks that have been explicitly disabled (default false)
260e353b
TO
2631 * @return mixed
2632 */
675e2573 2633 public static function check(&$messages, $statusNames = [], $includeDisabled = FALSE) {
9d3a367a 2634 return self::singleton()->invoke(['messages', 'statusNames', 'includeDisabled'],
675e2573
CW
2635 $messages, $statusNames, $includeDisabled,
2636 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2637 'civicrm_check'
2638 );
260e353b
TO
2639 }
2640
75c8a3f7
GC
2641 /**
2642 * This hook is called when a query string of the CSV Batch export is generated.
54957108 2643 *
2644 * @param string $query
2645 *
2646 * @return mixed
75c8a3f7
GC
2647 */
2648 public static function batchQuery(&$query) {
be2fb01f 2649 return self::singleton()->invoke(['query'], $query, self::$_nullObject,
75c8a3f7
GC
2650 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2651 'civicrm_batchQuery'
2652 );
2653 }
2654
7340e501
PN
2655 /**
2656 * This hook is called to alter Deferred revenue item values just before they are
2657 * inserted in civicrm_financial_trxn table
2658 *
2659 * @param array $deferredRevenues
f2a90daf 2660 * @param CRM_Contribute_BAO_Contribution $contributionDetails
7f35de6b 2661 * @param bool $update
7f35de6b
PN
2662 * @param string $context
2663 *
7340e501
PN
2664 * @return mixed
2665 */
7f35de6b 2666 public static function alterDeferredRevenueItems(&$deferredRevenues, $contributionDetails, $update, $context) {
be2fb01f 2667 return self::singleton()->invoke(['deferredRevenues', 'contributionDetails', 'update', 'context'], $deferredRevenues, $contributionDetails, $update, $context,
7f35de6b 2668 self::$_nullObject, self::$_nullObject, 'civicrm_alterDeferredRevenueItems'
7340e501
PN
2669 );
2670 }
2671
75c8a3f7
GC
2672 /**
2673 * This hook is called when the entries of the CSV Batch export are mapped.
54957108 2674 *
2675 * @param array $results
2676 * @param array $items
2677 *
2678 * @return mixed
75c8a3f7
GC
2679 */
2680 public static function batchItems(&$results, &$items) {
be2fb01f 2681 return self::singleton()->invoke(['results', 'items'], $results, $items,
75c8a3f7
GC
2682 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2683 'civicrm_batchItems'
2684 );
2685 }
2686
72e86d7d
CW
2687 /**
2688 * This hook is called when core resources are being loaded
2689 *
2690 * @see CRM_Core_Resources::coreResourceList
2691 *
2692 * @param array $list
e3c1e85b 2693 * @param string $region
72e86d7d 2694 */
e3c1e85b 2695 public static function coreResourceList(&$list, $region) {
be2fb01f 2696 self::singleton()->invoke(['list', 'region'], $list, $region,
e3c1e85b 2697 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
72e86d7d
CW
2698 'civicrm_coreResourceList'
2699 );
2700 }
2701
fd7c068f
CW
2702 /**
2703 * Allows the list of filters on the EntityRef widget to be altered.
2704 *
2705 * @see CRM_Core_Resources::entityRefFilters
2706 *
2707 * @param array $filters
7022db93 2708 * @param array $links
fd7c068f 2709 */
77d0bf4e
PN
2710 public static function entityRefFilters(&$filters, &$links = NULL) {
2711 self::singleton()->invoke(['filters', 'links'], $filters, $links, self::$_nullObject,
fd7c068f
CW
2712 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2713 'civicrm_entityRefFilters'
2714 );
2715 }
2716
aa00da9b 2717 /**
f3f00653 2718 * This hook is called for bypass a few civicrm urls from IDS check.
2719 *
2720 * @param array $skip list of civicrm urls
2721 *
2722 * @return mixed
aa00da9b 2723 */
2724 public static function idsException(&$skip) {
be2fb01f 2725 return self::singleton()->invoke(['skip'], $skip, self::$_nullObject,
aa00da9b 2726 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2727 'civicrm_idsException'
2728 );
2729 }
2730
e6209c6e
J
2731 /**
2732 * This hook is called when a geocoder's format method is called.
2733 *
4b62bfd8 2734 * @param string $geoProvider
e6209c6e
J
2735 * @param array $values
2736 * @param SimpleXMLElement $xml
f3f00653 2737 *
2738 * @return mixed
e6209c6e 2739 */
4b62bfd8 2740 public static function geocoderFormat($geoProvider, &$values, $xml) {
be2fb01f 2741 return self::singleton()->invoke(['geoProvider', 'values', 'xml'], $geoProvider, $values, $xml,
4b62bfd8 2742 self::$_nullObject, self::$_nullObject, self::$_nullObject,
e6209c6e
J
2743 'civicrm_geocoderFormat'
2744 );
2745 }
2746
0613768a
EE
2747 /**
2748 * This hook is called before an inbound SMS is processed.
2749 *
e97c66ff 2750 * @param \CRM_SMS_Message $message
6714d8d2 2751 * An SMS message received
caed3ddc
SL
2752 * @return mixed
2753 */
2754 public static function inboundSMS(&$message) {
be2fb01f 2755 return self::singleton()->invoke(['message'], $message, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_inboundSMS');
0613768a
EE
2756 }
2757
33f07374 2758 /**
2759 * This hook is called to modify api params of EntityRef form field
2760 *
2761 * @param array $params
6714d8d2 2762 * @param string $formName
33f07374 2763 * @return mixed
2764 */
f9585de5 2765 public static function alterEntityRefParams(&$params, $formName) {
be2fb01f 2766 return self::singleton()->invoke(['params', 'formName'], $params, $formName,
33f07374 2767 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2768 'civicrm_alterEntityRefParams'
2769 );
2770 }
2771
3eaa853f
TO
2772 /**
2773 * Fire `hook_civicrm_queueRun_{$runner}`.
2774 *
2775 * This event only fires if these conditions are met:
2776 *
2777 * 1. The `$queue` has been persisted in `civicrm_queue`.
2778 * 2. The `$queue` has a `runner` property.
2779 * 3. The `$queue` has some pending tasks.
2780 * 4. The system has a queue-running agent.
2781 *
2782 * @param \CRM_Queue_Queue $queue
2783 * @param array $items
2784 * List of claimed items which we may evaluate.
2785 * @param array $outcomes
2786 * The outcomes of each task. One of 'ok', 'retry', 'fail'.
2787 * Keys should match the keys in $items.
2788 */
2789 public static function queueRun(CRM_Queue_Queue $queue, array $items, &$outcomes) {
2790 $runner = $queue->getSpec('runner');
2791 if (empty($runner) || !preg_match(';^[A-Za-z0-9_]+$;', $runner)) {
2792 throw new \CRM_Core_Exception("Cannot autorun queue: " . $queue->getName());
2793 }
2794 return self::singleton()->invoke(['queue', 'items', 'outcomes'], $queue, $items,
2795 $outcomes, $exception, self::$_nullObject, self::$_nullObject,
2796 'civicrm_queueRun_' . $runner
2797 );
2798 }
2799
677170bd
TO
2800 /**
2801 * Fired if the status of a queue changes.
2802 *
2803 * @param \CRM_Queue_Queue $queue
2804 * @param string $status
2805 * New status.
2806 * Ex: 'completed', 'active', 'aborted'
2807 */
2808 public static function queueStatus(CRM_Queue_Queue $queue, string $status): void {
2809 self::singleton()->invoke(['queue', 'status'], $queue, $status,
2810 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2811 'civicrm_queueStatus'
2812 );
2813 }
2814
3eaa853f
TO
2815 /**
2816 * This is called if automatic execution of a queue-task fails.
2817 *
2818 * The `$outcome` may be modified. For example, you might inspect the $item and $exception -- and then
2819 * decide whether to 'retry', 'delete', or 'abort'.
2820 *
2821 * @param \CRM_Queue_Queue $queue
2822 * @param \CRM_Queue_DAO_QueueItem|\stdClass $item
2823 * The enqueued item $item.
2824 * In principle, this is the $item format determined by the queue, which includes `id` and `data`.
2825 * In practice, it is typically an instance of `CRM_Queue_DAO_QueueItem`.
2826 * @param string $outcome
2827 * The outcome of the task. Legal values:
2828 * - 'retry': The task encountered a problem, and it should be retried.
2829 * - 'delete': The task encountered a non-recoverable problem, and it should be deleted.
2830 * - 'abort': The task encountered a non-recoverable problem, and the queue should be stopped.
2831 * - 'ok': The task finished normally. (You won't generally see this, but it could be useful in some customizations.)
2832 * The default outcome for task-errors is determined by the queue settings (`civicrm_queue.error`).
2833 * @param \Throwable|null $exception
2834 * If the task failed, this is the cause of the failure.
2835 */
2836 public static function queueTaskError(CRM_Queue_Queue $queue, $item, &$outcome, ?Throwable $exception) {
2837 return self::singleton()->invoke(['job', 'params'], $queue, $item,
2838 $outcome, $exception, self::$_nullObject, self::$_nullObject,
2839 'civicrm_queueTaskError'
2840 );
2841 }
2842
912d0751
RT
2843 /**
2844 * This hook is called before a scheduled job is executed
2845 *
2846 * @param CRM_Core_DAO_Job $job
2847 * The job to be executed
2848 * @param array $params
2849 * The arguments to be given to the job
2850 */
2851 public static function preJob($job, $params) {
be2fb01f 2852 return self::singleton()->invoke(['job', 'params'], $job, $params,
912d0751
RT
2853 self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
2854 'civicrm_preJob'
2855 );
2856 }
2857
2858 /**
2859 * This hook is called after a scheduled job is executed
2860 *
2861 * @param CRM_Core_DAO_Job $job
2862 * The job that was executed
2863 * @param array $params
2864 * The arguments given to the job
2865 * @param array $result
2866 * The result of the API call, or the thrown exception if any
2867 */
2868 public static function postJob($job, $params, $result) {
be2fb01f 2869 return self::singleton()->invoke(['job', 'params', 'result'], $job, $params, $result,
912d0751
RT
2870 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2871 'civicrm_postJob'
2872 );
2873 }
2874
3417627c 2875 /**
2876 * This hook is called before and after constructing mail recipients.
2877 * Allows user to alter filter and/or search query to fetch mail recipients
2878 *
2879 * @param CRM_Mailing_DAO_Mailing $mailingObject
906298d3
TO
2880 * @param array $criteria
2881 * A list of SQL criteria; you can add/remove/replace/modify criteria.
2882 * Array(string $name => CRM_Utils_SQL_Select $criterion).
2883 * Ex: array('do_not_email' => CRM_Utils_SQL_Select::fragment()->where("$contact.do_not_email = 0")).
3417627c 2884 * @param string $context
906298d3
TO
2885 * Ex: 'pre', 'post'
2886 * @return mixed
3417627c 2887 */
906298d3 2888 public static function alterMailingRecipients(&$mailingObject, &$criteria, $context) {
be2fb01f 2889 return self::singleton()->invoke(['mailingObject', 'params', 'context'],
906298d3 2890 $mailingObject, $criteria, $context,
737f12a7 2891 self::$_nullObject, self::$_nullObject, self::$_nullObject,
3417627c 2892 'civicrm_alterMailingRecipients'
2893 );
2894 }
2895
2d39b9c0
SL
2896 /**
2897 * ALlow Extensions to custom process IPN hook data such as sending Google Analyitcs information based on the IPN
2898 * @param array $IPNData - Array of IPN Data
2899 * @return mixed
2900 */
2901 public static function postIPNProcess(&$IPNData) {
be2fb01f 2902 return self::singleton()->invoke(['IPNData'],
2d39b9c0
SL
2903 $IPNData, self::$_nullObject, self::$_nullObject,
2904 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2905 'civicrm_postIPNProcess'
2906 );
2907 }
2908
9fdf2f17
SL
2909 /**
2910 * Allow extensions to modify the array of acceptable fields to be included on profiles
2911 * @param array $fields
92f06cdd 2912 * format is [Entity => array of DAO fields]
9fdf2f17
SL
2913 * @return mixed
2914 */
2915 public static function alterUFFields(&$fields) {
2916 return self::singleton()->invoke(['fields'],
2917 $fields, self::$_nullObject, self::$_nullObject,
2918 self::$_nullObject, self::$_nullObject, self::$_nullObject,
2919 'civicrm_alterUFFields'
2920 );
2921 }
2922
21d40964
PN
2923 /**
2924 * This hook is called to alter Custom field value before its displayed.
2925 *
2926 * @param string $displayValue
2927 * @param mixed $value
2928 * @param int $entityId
2929 * @param array $fieldInfo
2930 *
2931 * @return mixed
2932 */
2933 public static function alterCustomFieldDisplayValue(&$displayValue, $value, $entityId, $fieldInfo) {
2934 return self::singleton()->invoke(
2935 ['displayValue', 'value', 'entityId', 'fieldInfo'],
2936 $displayValue, $value, $entityId, $fieldInfo, self::$_nullObject,
2937 self::$_nullObject, 'civicrm_alterCustomFieldDisplayValue'
2938 );
2939 }
2940
355881ac
SL
2941 /**
2942 * Alter APIv4 route permissions based on the Entity and Action
2943 *
c85dbf4e
TO
2944 * This is an experimental hook intended to *relax* the requirement
2945 * for "access AJAX API" when calling public-oriented APIs.
2946 *
2947 * Historically, when APIv2/v3 were first exposed to an HTTP interface, using
2948 * the HTTP interface required an extra permission "access AJAX API". This is a
2949 * broad hedge against security flaws within those API's. In the current APIv4
2950 * era, security concerns are often baked into each API, so there is a debate about
2951 * whether "access AJAX API" serves a purpose or just makes
2952 * administration/development more complicated. (So far, there's more support
2953 * for the latter.)
2954 *
2955 * This hook might foreseeably be abandoned either...
2956 *
2957 * - if it is found that "access AJAX API" guard is not needed for APIv4.
2958 * - if the policy is moved into metadata.
2959 *
355881ac
SL
2960 * @param array|string $permissions
2961 * @param string $entity
2962 * @param string $action
2963 *
2964 * @return mixed
2965 */
2966 public static function alterApiRoutePermissions(&$permissions, $entity, $action) {
2967 return self::singleton()->invoke(
2968 ['permissions', 'entity', 'action'],
2969 $permissions, $entity, $action, self::$_nullObject, self::$_nullObject,
2970 self::$_nullObject, 'civicrm_alterApiRoutePermissions'
2971 );
2972 }
2973
79e2d3ea
MW
2974 /**
2975 * Allows an extension to override the checksum validation.
2976 * For example you may want to invalidate checksums that were sent out/forwarded by mistake. You could also
2977 * intercept and redirect to a different page in this case - eg. to say "sorry, you tried to use a compromised
2978 * checksum".
2979 *
2980 * @param int $contactID
2981 * @param string $checksum
2982 * @param bool $invalid
2983 * Leave this at FALSE to allow the core code to perform validation. Set to TRUE to invalidate
2984 */
2985 public static function invalidateChecksum($contactID, $checksum, &$invalid) {
2986 return self::singleton()->invoke(
2987 ['contactID', 'checksum', 'invalid'],
2988 $contactID, $checksum, $invalid, self::$_nullObject, self::$_nullObject,
2989 self::$_nullObject, 'civicrm_invalidateChecksum'
2990 );
2991 }
2992
6a488035 2993}