}
catch (\Exception $e) {
if ($apiRequest) {
- $this->dispatcher->dispatch(Events::EXCEPTION, new ExceptionEvent($e, NULL, $apiRequest, $this));
+ $this->dispatcher->dispatch('civi.api.exception', new ExceptionEvent($e, NULL, $apiRequest, $this));
}
if ($e instanceof \PEAR_Exception) {
*/
public function runRequest($apiRequest) {
$this->boot($apiRequest);
- $errorScope = \CRM_Core_TemporaryErrorScope::useException();
list($apiProvider, $apiRequest) = $this->resolve($apiRequest);
$this->authorize($apiProvider, $apiRequest);
*/
public function boot($apiRequest) {
require_once 'api/Exception.php';
+ // the create error function loads some functions from utils
+ // so this require is also needed for apiv4 until such time as
+ // we alter create error.
+ require_once 'api/v3/utils.php';
switch ($apiRequest['version']) {
case 3:
if (!is_array($apiRequest['params'])) {
throw new \API_Exception('Input variable `params` is not an array', 2000);
}
- require_once 'api/v3/utils.php';
_civicrm_api3_initialize();
break;
*/
public function resolve($apiRequest) {
/** @var \Civi\API\Event\ResolveEvent $resolveEvent */
- $resolveEvent = $this->dispatcher->dispatch(Events::RESOLVE, new ResolveEvent($apiRequest, $this));
+ $resolveEvent = $this->dispatcher->dispatch('civi.api.resolve', new ResolveEvent($apiRequest, $this));
$apiRequest = $resolveEvent->getApiRequest();
if (!$resolveEvent->getApiProvider()) {
throw new \Civi\API\Exception\NotImplementedException("API (" . $apiRequest['entity'] . ", " . $apiRequest['action'] . ") does not exist (join the API team and implement it!)");
*/
public function authorize($apiProvider, $apiRequest) {
/** @var \Civi\API\Event\AuthorizeEvent $event */
- $event = $this->dispatcher->dispatch(Events::AUTHORIZE, new AuthorizeEvent($apiProvider, $apiRequest, $this));
+ $event = $this->dispatcher->dispatch('civi.api.authorize', new AuthorizeEvent($apiProvider, $apiRequest, $this));
if (!$event->isAuthorized()) {
throw new \Civi\API\Exception\UnauthorizedException("Authorization failed");
}
*/
public function prepare($apiProvider, $apiRequest) {
/** @var \Civi\API\Event\PrepareEvent $event */
- $event = $this->dispatcher->dispatch(Events::PREPARE, new PrepareEvent($apiProvider, $apiRequest, $this));
+ $event = $this->dispatcher->dispatch('civi.api.prepare', new PrepareEvent($apiProvider, $apiRequest, $this));
return [$event->getApiProvider(), $event->getApiRequest()];
}
*/
public function respond($apiProvider, $apiRequest, $result) {
/** @var \Civi\API\Event\RespondEvent $event */
- $event = $this->dispatcher->dispatch(Events::RESPOND, new RespondEvent($apiProvider, $apiRequest, $result, $this));
+ $event = $this->dispatcher->dispatch('civi.api.respond', new RespondEvent($apiProvider, $apiRequest, $result, $this));
return $event->getResponse();
}