3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
14 * The API kernel dispatches a series of events while processing each API request.
15 * For a successful API request, the sequence is RESOLVE => AUTHORIZE => PREPARE => RESPOND.
16 * If an exception arises in any stage, then the sequence is aborted and the EXCEPTION
17 * event is dispatched.
19 * Event subscribers which are concerned about the order of execution should assign
20 * a priority to their subscription (such as W_EARLY, W_MIDDLE, or W_LATE).
26 * @deprecated - You may simply use the event name directly. dev/core#1744
28 const AUTHORIZE
= 'civi.api.authorize';
32 * @deprecated - You may simply use the event name directly. dev/core#1744
34 const RESOLVE
= 'civi.api.resolve';
38 * @deprecated - You may simply use the event name directly. dev/core#1744
40 const PREPARE
= 'civi.api.prepare';
43 * Apply post-execution logic
46 * @deprecated - You may simply use the event name directly. dev/core#1744
48 const RESPOND
= 'civi.api.respond';
51 * Handle any exceptions.
54 * @deprecated - You may simply use the event name directly. dev/core#1744
56 const EXCEPTION
= 'civi.api.exception';
59 * Priority - Higher numbers execute earlier
69 * Priority - Lower numbers execute later
74 * @return array<string>
76 public static function allEvents() {
87 * @param \Civi\Core\Event\GenericHookEvent $e
88 * @see \CRM_Utils_Hook::eventDefs
90 public static function hookEventDefs($e) {
91 $e->inspector
->addEventClass('civi.api.authorize', 'Civi\API\Event\AuthorizeEvent');
92 $e->inspector
->addEventClass('civi.api.exception', 'Civi\API\Event\ExceptionEvent');
93 $e->inspector
->addEventClass('civi.api.prepare', 'Civi\API\Event\PrepareEvent');
94 $e->inspector
->addEventClass('civi.api.resolve', 'Civi\API\Event\ResolveEvent');
95 $e->inspector
->addEventClass('civi.api.respond', 'Civi\API\Event\RespondEvent');