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 +--------------------------------------------------------------------+
12 namespace Civi\API\Event
;
14 use Civi\API\Provider\WrappingProvider
;
18 * @package Civi\API\Event
20 class PrepareEvent
extends Event
{
23 * @param array $apiRequest
24 * The full description of the API request.
25 * @return PrepareEvent
27 public function setApiRequest($apiRequest) {
28 $this->apiRequest
= $apiRequest;
33 * Replace the normal implementation of an API call with some wrapper.
35 * The wrapper has discretion to call -- or not call -- or iterate with --
36 * the original API implementation, with original or substituted arguments.
40 * $event->wrapApi(function($apiRequest, $continue){
42 * $continue($apiRequest);
46 * @param callable $callback
47 * The custom API implementation.
48 * Function(array $apiRequest, callable $continue).
49 * @return PrepareEvent
51 public function wrapApi($callback) {
52 $this->apiProvider
= new WrappingProvider($callback, $this->apiProvider
);