vendor/knplabs/knp-components/src/Knp/Component/Pager/Event/Subscriber/Paginate/Doctrine/ODM/PHPCR/QuerySubscriber.php line 14

Open in your IDE?
  1. <?php
  2. namespace Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine\ODM\PHPCR;
  3. use Doctrine\ODM\PHPCR\Query\Query;
  4. use Knp\Component\Pager\Event\ItemsEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. /**
  7.  * @author Martin HasoĊˆ <martin.hason@gmail.com>
  8.  */
  9. class QuerySubscriber implements EventSubscriberInterface
  10. {
  11.     public function items(ItemsEvent $event): void
  12.     {
  13.         if (!$event->target instanceof Query) {
  14.             return;
  15.         }
  16.         $queryCount = clone $event->target;
  17.         $event->count $queryCount->execute(nullQuery::HYDRATE_PHPCR)->getRows()->count();
  18.         $query $event->target;
  19.         $query->setMaxResults($event->getLimit());
  20.         $query->setFirstResult($event->getOffset());
  21.         $event->items $query->execute();
  22.         $event->stopPropagation();
  23.     }
  24.     public static function getSubscribedEvents(): array
  25.     {
  26.         return [
  27.             'knp_pager.items' => ['items'0],
  28.         ];
  29.     }
  30. }