src/EventSubscriber/NotFoundSubscriber.php line 19

Open in your IDE?
  1. <?php 
  2. namespace App\EventSubscriber;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Symfony\Component\HttpKernel\Event\ExceptionEvent;
  5. use Symfony\Component\HttpKernel\KernelEvents;
  6. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  7. use Symfony\Component\HttpFoundation\RedirectResponse;
  8. class NotFoundSubscriber implements EventSubscriberInterface
  9. {
  10.     public static function getSubscribedEvents()
  11.     {
  12.         return [
  13.             KernelEvents::EXCEPTION => 'onKernelException',
  14.         ];
  15.     }
  16.     public function onKernelException(ExceptionEvent $event)
  17.     {
  18.         $exception $event->getThrowable();
  19.         if ($exception instanceof NotFoundHttpException) {
  20.           
  21.             $response = new RedirectResponse('/securegxcontrol/dashboard');
  22.             $event->setResponse($response);
  23.             
  24.         }
  25.     }
  26. }