PhalconRest\Middleware\AuthorizationMiddleware::beforeExecuteRoute PHP Method

beforeExecuteRoute() public method

public beforeExecuteRoute ( Phalcon\Events\Event $event, Api $api )
$event Phalcon\Events\Event
$api PhalconRest\Api
    public function beforeExecuteRoute(Event $event, Api $api)
    {
        $collection = $api->getMatchedCollection();
        $endpoint = $api->getMatchedEndpoint();
        if (!$collection || !$endpoint) {
            return;
        }
        $allowed = $this->acl->isAllowed($this->userService->getRole(), $collection->getIdentifier(), $endpoint->getIdentifier());
        if (!$allowed) {
            throw new Exception(ErrorCodes::ACCESS_DENIED);
        }
    }
AuthorizationMiddleware