vendor/knplabs/knp-components/src/Knp/Component/Pager/Event/Subscriber/Paginate/Doctrine/ODM/MongoDB/QueryBuilderSubscriber.php line 12

Open in your IDE?
  1. <?php
  2. namespace Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine\ODM\MongoDB;
  3. use Doctrine\ODM\MongoDB\Query\Builder;
  4. use Knp\Component\Pager\Event\ItemsEvent;
  5. use Knp\Component\Pager\PaginatorInterface;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class QueryBuilderSubscriber implements EventSubscriberInterface
  8. {
  9.     public function items(ItemsEvent $event): void
  10.     {
  11.         if ($event->target instanceof Builder) {
  12.             // change target into query
  13.             $event->target $event->target->getQuery($event->options[PaginatorInterface::ODM_QUERY_OPTIONS] ?? []);
  14.         }
  15.     }
  16.     public static function getSubscribedEvents(): array
  17.     {
  18.         return [
  19.             'knp_pager.items' => ['items'10/*make sure to transform before any further modifications*/],
  20.         ];
  21.     }
  22. }