<?php
namespace App\EventListener;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
class KernelRequest
{
private $session;
public function __construct(SessionInterface $session)
{
$this->session = $session;
}
public function onKernelRequest(RequestEvent $event)
{
if (!$event->isMainRequest()) {
return;
}
// Get the Request.
$request = $event->getRequest();
$currentRoute = $request->attributes->get('_route');
if ($currentRoute !== 'app_user_index') {
// $this->session->remove('app_user_index.user_search_key');
}
}
}