1 <?php 
declare(strict_types
=1); 
   4  * This file is part of the Rapsys AirBundle package. 
   6  * (c) Raphaël Gertz <symfony@rapsys.eu> 
   8  * For the full copyright and license information, please view the LICENSE 
   9  * file that was distributed with this source code. 
  12 namespace Rapsys\AirBundle\Handler
; 
  14 use Symfony\Component\HttpFoundation\Request
; 
  15 use Symfony\Component\HttpFoundation\Response
; 
  16 use Symfony\Component\Security\Core\Exception\AccessDeniedException
; 
  17 use Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface
; 
  19 use Rapsys\AirBundle\RapsysAirBundle
; 
  20 use Rapsys\AirBundle\Controller\AbstractController
; 
  25 class AccessDeniedHandler 
extends AbstractController 
implements AccessDeniedHandlerInterface 
{ 
  29         public function handle(Request 
$request, AccessDeniedException 
$exception): Response 
{ 
  31                 $this->context
['title'] = $this->translator
->trans('Access denied'); 
  34                 //XXX: we assume that it's already translated 
  35                 $this->context
['message'] = $exception->getMessage(); 
  38                 if ($this->checker
->isGranted('ROLE_ADMIN')) { 
  40                         $this->context
['trace'] = $exception->getTraceAsString(); 
  44                 $response = $this->render('@RapsysAir/security/denied.html.twig', $this->context
); 
  45                 $response->setStatusCode(403); 
  46                 $response->setEtag(md5($response->getContent())); 
  47                 $response->setPublic(); 
  48                 $response->isNotModified($request);