Baikal\FrontendBundle\Service\AccessDeniedHandler::handle PHP Method

handle() public method

Handles an access denied failure.
public handle ( Request $request, Symfony\Component\Security\Core\Exception\AccessDeniedException $accessDeniedException ) : Response
$request Symfony\Component\HttpFoundation\Request
$accessDeniedException Symfony\Component\Security\Core\Exception\AccessDeniedException
return Response may return null
    public function handle(Request $request, AccessDeniedException $accessDeniedException)
    {
        # First we check if user has an access granted to the admin
        if ($this->securityContext->isGranted('ROLE_ADMIN') || $this->securityContext->isGranted('ROLE_STATIC_ADMIN')) {
            return new RedirectResponse($this->router->generate('baikal_admin_homepage'));
        }
        # If not, we display an "Access denied" message
        $attributes = array('_controller' => 'BaikalCoreBundle:Security:accessDenied', 'exception' => $accessDeniedException);
        $subRequest = $request->duplicate(array(), null, $attributes);
        return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
    }
AccessDeniedHandler