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