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

Open in your IDE?
  1. <?php
  2. namespace Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Knp\Component\Pager\Event\ItemsEvent;
  5. use ArrayObject;
  6. use Doctrine\Common\Collections\Collection;
  7. class CollectionSubscriber implements EventSubscriberInterface
  8. {
  9.     public function items(ItemsEvent $event)
  10.     {
  11.         if ($event->target instanceof Collection) {
  12.             $event->count $event->target->count();
  13.             $event->items = new ArrayObject($event->target->slice(
  14.                 $event->getOffset(),
  15.                 $event->getLimit()
  16.             ));
  17.             $event->stopPropagation();
  18.         }
  19.     }
  20.     public static function getSubscribedEvents()
  21.     {
  22.         return array(
  23.             'knp_pager.items' => array('items'0)
  24.         );
  25.     }
  26. }