dev/core#1744 - Civi/API - Simplify event naming
[civicrm-core.git] / Civi / API / Events.php
index ff6f4caa1d5ad2aea4def1c623365f1d041bc61f..6bbecb8f037f46d0362c7b5bb772280181a450e8 100644 (file)
@@ -22,27 +22,20 @@ namespace Civi\API;
 class Events {
 
   /**
-   * Determine whether the API request is allowed for the current user.
-   * For successful execution, at least one listener must invoke
-   * $event->authorize().
-   *
    * @see AuthorizeEvent
+   * @deprecated - You may simply use the event name directly. dev/core#1744
    */
   const AUTHORIZE = 'civi.api.authorize';
 
   /**
-   * Determine which API provider executes the given request. For successful
-   * execution, at least one listener must invoke
-   * $event->setProvider($provider).
-   *
    * @see ResolveEvent
+   * @deprecated - You may simply use the event name directly. dev/core#1744
    */
   const RESOLVE = 'civi.api.resolve';
 
   /**
-   * Apply pre-execution logic
-   *
    * @see PrepareEvent
+   * @deprecated - You may simply use the event name directly. dev/core#1744
    */
   const PREPARE = 'civi.api.prepare';
 
@@ -50,6 +43,7 @@ class Events {
    * Apply post-execution logic
    *
    * @see RespondEvent
+   * @deprecated - You may simply use the event name directly. dev/core#1744
    */
   const RESPOND = 'civi.api.respond';
 
@@ -57,6 +51,7 @@ class Events {
    * Handle any exceptions.
    *
    * @see ExceptionEvent
+   * @deprecated - You may simply use the event name directly. dev/core#1744
    */
   const EXCEPTION = 'civi.api.exception';
 
@@ -80,11 +75,11 @@ class Events {
    */
   public static function allEvents() {
     return [
-      self::AUTHORIZE,
-      self::EXCEPTION,
-      self::PREPARE,
-      self::RESOLVE,
-      self::RESPOND,
+      'civi.api.authorize',
+      'civi.api.exception',
+      'civi.api.prepare',
+      'civi.api.resolve',
+      'civi.api.respond',
     ];
   }
 
@@ -93,11 +88,11 @@ class Events {
    * @see \CRM_Utils_Hook::eventDefs
    */
   public static function hookEventDefs($e) {
-    $e->inspector->addEventClass(self::AUTHORIZE, 'Civi\API\Event\AuthorizeEvent');
-    $e->inspector->addEventClass(self::EXCEPTION, 'Civi\API\Event\ExceptionEvent');
-    $e->inspector->addEventClass(self::PREPARE, 'Civi\API\Event\PrepareEvent');
-    $e->inspector->addEventClass(self::RESOLVE, 'Civi\API\Event\ResolveEvent');
-    $e->inspector->addEventClass(self::RESPOND, 'Civi\API\Event\RespondEvent');
+    $e->inspector->addEventClass('civi.api.authorize', 'Civi\API\Event\AuthorizeEvent');
+    $e->inspector->addEventClass('civi.api.exception', 'Civi\API\Event\ExceptionEvent');
+    $e->inspector->addEventClass('civi.api.prepare', 'Civi\API\Event\PrepareEvent');
+    $e->inspector->addEventClass('civi.api.resolve', 'Civi\API\Event\ResolveEvent');
+    $e->inspector->addEventClass('civi.api.respond', 'Civi\API\Event\RespondEvent');
   }
 
 }