vendor/white-october/pagerfanta-bundle/EventListener/ConvertNotValidMaxPerPageToNotFoundListener.php line 15

Open in your IDE?
  1. <?php
  2. namespace  WhiteOctober\PagerfantaBundle\EventListener;
  3. use Pagerfanta\Exception\NotValidMaxPerPageException;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
  6. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  7. use Symfony\Component\HttpKernel\KernelEvents;
  8. class ConvertNotValidMaxPerPageToNotFoundListener implements EventSubscriberInterface
  9. {
  10.     /**
  11.      * @param GetResponseForExceptionEvent $event
  12.      */
  13.     public function onException(GetResponseForExceptionEvent $event)
  14.     {
  15.         if (method_exists($event'getThrowable')) {
  16.             $throwable $event->getThrowable();
  17.         } else {
  18.             // Support for Symfony 4.3 and before
  19.             $throwable $event->getException();
  20.         }
  21.         if ($throwable instanceof NotValidMaxPerPageException) {
  22.             $notFoundHttpException = new NotFoundHttpException('Page Not Found'$throwable);
  23.             if (method_exists($event'setThrowable')) {
  24.                 $event->setThrowable($notFoundHttpException);
  25.             } else {
  26.                 // Support for Symfony 4.3 and before
  27.                 $event->setException($notFoundHttpException);
  28.             }
  29.         }
  30.     }
  31.     /**
  32.      * {@inheritDoc}
  33.      */
  34.     public static function getSubscribedEvents()
  35.     {
  36.         return array(
  37.             KernelEvents::EXCEPTION => array('onException'512)
  38.         );
  39.     }
  40. }