<?php
namespace App\EventListener;
use App\Event\EmptyCookieExceptionEvent;
use App\Exception\EmptyCookieException;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
final class EmptyCookieExceptionListener
{
public function __invoke(ExceptionEvent $event): void {
/**
* @var $exception \Exception
*/
$exception = $event->getThrowable();
if(get_class($exception) === EmptyCookieException::class) {
$event->setResponse(new RedirectResponse("/login"));
}/* else {
throw $exception;
}*/
}
}