src/EventListener/KernelRequest.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  4. use Symfony\Component\HttpKernel\Event\RequestEvent;
  5. class KernelRequest
  6. {
  7.     private $session;
  8.     public function __construct(SessionInterface $session)
  9.     {
  10.         $this->session $session;
  11.     }
  12.     public function onKernelRequest(RequestEvent $event)
  13.     {
  14.         if (!$event->isMainRequest()) {
  15.             return;
  16.         }
  17.         // Get the Request.
  18.         $request $event->getRequest();
  19.         $currentRoute $request->attributes->get('_route');
  20.         if ($currentRoute !== 'app_user_index') {
  21.             // $this->session->remove('app_user_index.user_search_key');
  22.         }
  23.     }
  24. }