vendor/babdev/pagerfanta-bundle/src/EventListener/ConvertNotValidMaxPerPageToNotFoundListener.php line 11

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace BabDev\PagerfantaBundle\EventListener;
  3. use Pagerfanta\Exception\NotValidMaxPerPageException;
  4. use Symfony\Component\HttpKernel\Event\ExceptionEvent;
  5. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  6. final class ConvertNotValidMaxPerPageToNotFoundListener
  7. {
  8. public function onKernelException(ExceptionEvent $event): void
  9. {
  10. $throwable = $event->getThrowable();
  11. if ($throwable instanceof NotValidMaxPerPageException) {
  12. $event->setThrowable(new NotFoundHttpException('Page Not Found', $throwable));
  13. }
  14. }
  15. }