3 namespace Rapsys\AirBundle\Security
; 
   5 use Symfony\Component\HttpFoundation\Request
; 
   6 use Symfony\Component\HttpFoundation\Response
; 
   7 use Symfony\Component\Security\Core\Exception\AccessDeniedException
; 
   8 use Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface
; 
   9 use Symfony\Component\DependencyInjection\ContainerInterface
; 
  10 use Symfony\Component\Translation\TranslatorInterface
; 
  13 class AccessDeniedHandler 
implements AccessDeniedHandlerInterface 
{ 
  18         protected $translator; 
  20         //Environment instance 
  21         protected $environment; 
  26         public function __construct(ContainerInterface 
$container, TranslatorInterface 
$translator, Environment 
$environment) { 
  28                 $this->config 
= $container->getParameter($this->getAlias()); 
  31                 $this->translator 
= $translator; 
  34                 $this->environment 
= $environment; 
  40 #use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; 
  41         #public function login(Request $request, AuthenticationUtils $authenticationUtils) { 
  42         public function handle(Request 
$request, AccessDeniedException 
$accessDeniedException) { 
  44                 $section = $this->translator
->trans('Access denied'); 
  47                 $title = $section.' - '.$this->translator
->trans($this->config
['site']['title']); 
  50                 $message = $this->translator
->trans($accessDeniedException->getMessage()); 
  54                         $this->environment
->render( 
  55                                 '@RapsysAir/security/denied.html.twig', 
  56                                 ['title' => $title, 'section' => $section, 'message' => $message] 
  65         public function getAlias() {