src/EventListener/EmptyCookieExceptionListener.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use App\Event\EmptyCookieExceptionEvent;
  4. use App\Exception\EmptyCookieException;
  5. use Symfony\Component\HttpFoundation\RedirectResponse;
  6. use Symfony\Component\HttpKernel\Event\ExceptionEvent;
  7. final class EmptyCookieExceptionListener
  8. {
  9.     public function __invoke(ExceptionEvent $event): void {
  10.         /**
  11.          * @var $exception \Exception
  12.          */
  13.         $exception $event->getThrowable();
  14.         if(get_class($exception) === EmptyCookieException::class) {
  15.             $event->setResponse(new RedirectResponse("/login"));
  16.         }/* else {
  17.             throw $exception;
  18.         }*/
  19.     }
  20. }