context = $context; $this->accessDecisionManager = $accessDecisionManager; $this->map = $map; $this->router = $router; } public function setRoute($route) { $this->route = $route; return $this; } public function isGranted(array $restrictedRoles = array()) { if (null === $token = $this->context->getToken()) { return true; } $request = Request::create($this->route); list($attributes) = $this->map->getPatterns($request); if (null === $attributes) { return true; } if (!$token->isAuthenticated()) { return false; } $access = $this->accessDecisionManager->decide($token, $attributes, $request); if (!$access) { return false; } if (!empty($restrictedRoles)) { foreach ($restrictedRoles as $k => $v) { if (!$this->context->isGranted($v)) { return false; } } } return true; } }