vendor/pimcore/pimcore/lib/Model/Paginator/EventSubscriber/PaginateListingSubscriber.php line 11

Open in your IDE?
  1. <?php
  2. namespace Pimcore\Model\Paginator\EventSubscriber;
  3. use Knp\Component\Pager\Event\ItemsEvent;
  4. use Pimcore\Model\Paginator\PaginateListingInterface;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class PaginateListingSubscriber implements EventSubscriberInterface
  7. {
  8.     public function items(ItemsEvent $event)
  9.     {
  10.         $paginationAdapter $event->target;
  11.         if ($paginationAdapter instanceof PaginateListingInterface) {
  12.             $event->count $paginationAdapter->count();
  13.             $items $paginationAdapter->getItems($event->getOffset(), $event->getLimit());
  14.             $event->items $items;
  15.             $event->stopPropagation();
  16.         }
  17.         if (!$event->isPropagationStopped()) {
  18.             throw new \RuntimeException('Paginator only accepts instances of the type ' .
  19.                 PaginateListingInterface::class . ' or types defined here: https://github.com/KnpLabs/KnpPaginatorBundle#controller');
  20.         }
  21.     }
  22.     public static function getSubscribedEvents(): array
  23.     {
  24.         return [
  25.             'knp_pager.items' => ['items', -5/* other data listeners should be analyzed first*/],
  26.         ];
  27.     }
  28. }