public getMatchedEndpoint ( ) : |
||
return | The matched endpoint |
public function getMatchedEndpoint()
{
$collectionIdentifier = $this->getMatchedRouteNamePart('collection');
$endpointIdentifier = $this->getMatchedRouteNamePart('endpoint');
if (!$endpointIdentifier) {
return null;
}
$fullIdentifier = $collectionIdentifier . ' ' . $endpointIdentifier;
return array_key_exists($fullIdentifier, $this->endpointsByIdentifier) ? $this->endpointsByIdentifier[$fullIdentifier] : null;
}
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); } }