vendor/knplabs/knp-components/src/Knp/Component/Pager/Event/Subscriber/Filtration/FiltrationSubscriber.php line 15

Open in your IDE?
  1. <?php
  2. namespace Knp\Component\Pager\Event\Subscriber\Filtration;
  3. use Knp\Component\Pager\Event\BeforeEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. class FiltrationSubscriber implements EventSubscriberInterface
  6. {
  7.     /**
  8.      * Lazy-load state tracker
  9.      */
  10.     private bool $isLoaded false;
  11.     public function before(BeforeEvent $event): void
  12.     {
  13.         // Do not lazy-load more than once
  14.         if ($this->isLoaded) {
  15.             return;
  16.         }
  17.         /** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */
  18.         $dispatcher $event->getEventDispatcher();
  19.         // hook all standard filtration subscribers
  20.         $dispatcher->addSubscriber(new Doctrine\ORM\QuerySubscriber($event->getRequest()));
  21.         $dispatcher->addSubscriber(new PropelQuerySubscriber($event->getRequest()));
  22.         $this->isLoaded true;
  23.     }
  24.     public static function getSubscribedEvents(): array
  25.     {
  26.         return [
  27.             'knp_pager.before' => ['before'1],
  28.         ];
  29.     }
  30. }