vendor/knplabs/knp-components/src/Knp/Component/Pager/Event/Subscriber/Paginate/Callback/CallbackSubscriber.php line 15

Open in your IDE?
  1. <?php
  2. namespace Knp\Component\Pager\Event\Subscriber\Paginate\Callback;
  3. use Knp\Component\Pager\Event\ItemsEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. /**
  6.  * Callback pagination.
  7.  *
  8.  * @author Piotr Pelczar <me@athlan.pl>
  9.  */
  10. class CallbackSubscriber implements EventSubscriberInterface
  11. {
  12.     public function items(ItemsEvent $event): void
  13.     {
  14.         if ($event->target instanceof CallbackPagination) {
  15.             $event->count $event->target->getPaginationCount();
  16.             if($event->count 0) {
  17.                 $event->items $event->target->getPaginationItems($event->getOffset(), $event->getLimit());
  18.             }
  19.             else {
  20.                 $event->items = [];
  21.             }
  22.             $event->stopPropagation();
  23.         }
  24.     }
  25.     public static function getSubscribedEvents(): array
  26.     {
  27.         return [
  28.             'knp_pager.items' => ['items'0],
  29.         ];
  30.     }
  31. }