/** * Performs the specified access check. * * @param string $service_id * The access check service ID to use. * @param \Symfony\Component\Routing\Route $route * The route to check access to. * @param \Symfony\Component\HttpFoundation\Request $request * The incoming request object. * @param \Drupal\Core\Session\AccountInterface $account * The current user. * * @throws \Drupal\Core\Access\AccessException * Thrown when the access check returns an invalid value. * * @return string * A \Drupal\Core\Access\AccessInterface constant value. */ protected function performCheck($service_id, $route, $request, $account) { $callable = array($this->checks[$service_id], $this->checkMethods[$service_id]); $arguments = $this->argumentsResolver->getArguments($callable, $route, $request, $account); $service_access = call_user_func_array($callable, $arguments); if (!in_array($service_access, array(AccessInterface::ALLOW, AccessInterface::DENY, AccessInterface::KILL), TRUE)) { throw new AccessException("Access error in {$service_id}. Access services can only return AccessInterface::ALLOW, AccessInterface::DENY, or AccessInterface::KILL constants."); } return $service_access; }
/** * Checks access for the account and route using the custom access checker. * * @param \Symfony\Component\Routing\Route $route * The route to check against. * @param \Symfony\Component\HttpFoundation\Request $request * The request object. * @param \Drupal\Core\Session\AccountInterface $account * The currently logged in account. * * @return string * A \Drupal\Core\Access\AccessInterface constant value. */ public function access(Route $route, Request $request, AccountInterface $account) { $callable = $this->controllerResolver->getControllerFromDefinition($route->getRequirement('_custom_access')); $arguments = $this->argumentsResolver->getArguments($callable, $route, $request, $account); return call_user_func_array($callable, $arguments); }