Checks a route against applicable access check services.
Determines whether the route is accessible or not.
\Symfony\Component\Routing\Route $route: The route to check access to.
\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException If any access check denies access or none explicitly approve.
public function check(Route $route) {
$access = FALSE;
$checks = $route
->getOption('_access_checks') ?: array();
// No checks == deny by default.
foreach ($checks as $service_id) {
if (empty($this->checks[$service_id])) {
$this
->loadCheck($service_id);
}
$access = $this->checks[$service_id]
->access($route, $this->request);
if ($access === FALSE) {
// A check has denied access, no need to continue checking.
break;
}
}
// Access has been denied or not explicily approved.
if (!$access) {
throw new AccessDeniedHttpException();
}
}