src/Package/Openform/EventSubscriber/ChangerListener.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Package\Openform\EventSubscriber;
  3. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  4. use Symfony\Component\HttpFoundation\RedirectResponse;
  5. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  6. class ChangerListener
  7. {
  8.     /**
  9.      * Ten event wylapie nieobsluzony changeLang w controlerze
  10.      *
  11.      * @param ResponseEvent $event
  12.      * @return void
  13.      */
  14.     public function onKernelResponse(ResponseEvent $event)
  15.     {
  16.         $response $event->getResponse();
  17.         if (!$response instanceof RedirectResponse) {
  18.             $request $event->getRequest();
  19.             if (strpos($request->get('_route'), 'changer_') === 0) {
  20.                 throw new NotFoundHttpException('Not found. Try to define onChangeLocale in ' $request->get('_controller') . '');
  21.             }
  22.         }
  23.     }
  24. }