| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | Copyright CiviCRM LLC. All rights reserved. | |
| 5 | | | |
| 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 | +--------------------------------------------------------------------+ |
| 10 | */ |
| 11 | |
| 12 | namespace Civi\API\Event; |
| 13 | |
| 14 | /** |
| 15 | * Class RespondEvent |
| 16 | * @package Civi\API\Event |
| 17 | * |
| 18 | * Apply post-execution filtering to the API request/response. |
| 19 | * |
| 20 | * Event name: 'civi.api.respond' |
| 21 | */ |
| 22 | class RespondEvent extends Event { |
| 23 | /** |
| 24 | * @var mixed |
| 25 | */ |
| 26 | private $response; |
| 27 | |
| 28 | /** |
| 29 | * @param \Civi\API\Provider\ProviderInterface $apiProvider |
| 30 | * The API provider responsible for executing the request. |
| 31 | * @param array $apiRequest |
| 32 | * The full description of the API request. |
| 33 | * @param mixed $response |
| 34 | * The response to return to the client. |
| 35 | * @param \Civi\API\Kernel $apiKernel |
| 36 | * The kernel which fired the event. |
| 37 | */ |
| 38 | public function __construct($apiProvider, $apiRequest, $response, $apiKernel) { |
| 39 | $this->response = $response; |
| 40 | parent::__construct($apiProvider, $apiRequest, $apiKernel); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * @return mixed |
| 45 | */ |
| 46 | public function getResponse() { |
| 47 | return $this->response; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * @param mixed $response |
| 52 | * The response to return to the client. |
| 53 | */ |
| 54 | public function setResponse($response) { |
| 55 | $this->response = $response; |
| 56 | } |
| 57 | |
| 58 | } |