Merge pull request #4999 from totten/master-autosave
[civicrm-core.git] / Civi / API / Events.php
index 36d9af45fa8b825df00241ad95afa51100b6069b..cc51ff6258d62603be2dc61baefe64311f3f8e07 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 namespace Civi\API;
 
 /**
  * The API kernel dispatches a series of events while processing each API request.
- * For a successful API request, the sequence is AUTHORIZE => PREPARE => RESPOND.
+ * For a successful API request, the sequence is RESOLVE => AUTHORIZE => PREPARE => RESPOND.
  * If an exception arises in any stage, then the sequence is aborted and the EXCEPTION
  * event is dispatched.
  *
  * Event subscribers which are concerned about the order of execution should assign
  * a weight to their subscription (such as W_EARLY, W_MIDDLE, or W_LATE).
+ * W_LATE).
  */
 class Events {
 
   /**
    * Determine whether the API request is allowed for the current user.
-   * For successful execution, at least one listener must invoke $event->authorize().
+   * For successful execution, at least one listener must invoke
+   * $event->authorize().
    *
    * @see AuthorizeEvent
    */
   const AUTHORIZE = 'api.authorize';
 
+  /**
+   * Determine which API provider executes the given request. For successful
+   * execution, at least one listener must invoke
+   * $event->setProvider($provider).
+   *
+   * @see ResolveEvent
+   */
+  const RESOLVE = 'api.resolve';
+
   /**
    * Apply pre-execution logic
    *
@@ -80,4 +91,18 @@ class Events {
    * Weight - Late
    */
   const W_LATE = -100;
+
+  /**
+   * @return array<string>
+   */
+  public static function allEvents() {
+    return array(
+      self::AUTHORIZE,
+      self::EXCEPTION,
+      self::PREPARE,
+      self::RESOLVE,
+      self::RESPOND,
+    );
+  }
+
 }