Verifies that the current user can access the requested path.
\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: The Event to process.
public function onKernelRequestAccessCheck(GetResponseEvent $event) {
$request = $event
->getRequest();
if (!$request->attributes
->has(RouteObjectInterface::ROUTE_OBJECT)) {
// If no Route is available it is likely a static resource and access is
// handled elsewhere.
return;
}
$access = $this->accessManager
->check($request->attributes
->get(RouteObjectInterface::ROUTE_OBJECT), $request);
if (!$access) {
throw new AccessDeniedHttpException();
}
}