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

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.      * @var bool
  10.      */
  11.     private $isLoaded false;
  12.     public function before(BeforeEvent $event): void
  13.     {
  14.         // Do not lazy-load more than once
  15.         if ($this->isLoaded) {
  16.             return;
  17.         }
  18.         /** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */
  19.         $dispatcher $event->getEventDispatcher();
  20.         // hook all standard filtration subscribers
  21.         $dispatcher->addSubscriber(new Doctrine\ORM\QuerySubscriber($event->getRequest()));
  22.         $dispatcher->addSubscriber(new PropelQuerySubscriber($event->getRequest()));
  23.         $this->isLoaded true;
  24.     }
  25.     public static function getSubscribedEvents(): array
  26.     {
  27.         return [
  28.             'knp_pager.before' => ['before'1],
  29.         ];
  30.     }
  31. }