3 namespace Rapsys\AirBundle\Handler
;
5 use Symfony\Component\HttpFoundation\Request
;
6 use Symfony\Component\Security\Core\Exception\AccessDeniedException
;
7 use Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface
;
9 use Rapsys\AirBundle\RapsysAirBundle
;
10 use Rapsys\AirBundle\Controller\AbstractController
;
15 class AccessDeniedHandler
extends AbstractController
implements AccessDeniedHandlerInterface
{
19 public function handle(Request
$request, AccessDeniedException
$exception) {
21 $this->context
['title'] = $this->translator
->trans('Access denied');
24 //XXX: we assume that it's already translated
25 $this->context
['message'] = $exception->getMessage();
28 if ($this->isGranted('ROLE_ADMIN')) {
30 $this->context
['trace'] = $exception->getTraceAsString();
34 $response = $this->render('@RapsysAir/security/denied.html.twig', $this->context
);
35 $response->setStatusCode(403);
36 $response->setEtag(md5($response->getContent()));
37 $response->setPublic();
38 $response->isNotModified($request);