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