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