From 226ea4bfea523076b26e9135dbe174cb692be856 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Fri, 20 Sep 2024 10:37:34 +0200 Subject: [PATCH] Pass `$options` in `knp_pager.before` event --- src/Knp/Component/Pager/Event/BeforeEvent.php | 8 +++++++- src/Knp/Component/Pager/Paginator.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Knp/Component/Pager/Event/BeforeEvent.php b/src/Knp/Component/Pager/Event/BeforeEvent.php index 7365e604..bddd7b03 100644 --- a/src/Knp/Component/Pager/Event/BeforeEvent.php +++ b/src/Knp/Component/Pager/Event/BeforeEvent.php @@ -15,7 +15,8 @@ final class BeforeEvent extends Event public function __construct( private readonly EventDispatcherInterface $eventDispatcher, private readonly ArgumentAccessInterface $argumentAccess, - private readonly ?Connection $connection = null + private readonly ?Connection $connection = null, + private array &$options = [], ) { } @@ -29,6 +30,11 @@ public function getArgumentAccess(): ArgumentAccessInterface return $this->argumentAccess; } + public function &getOptions(): array + { + return $this->options; + } + public function getConnection(): ?Connection { return $this->connection; diff --git a/src/Knp/Component/Pager/Paginator.php b/src/Knp/Component/Pager/Paginator.php index bf1aa3b9..cc57a1eb 100644 --- a/src/Knp/Component/Pager/Paginator.php +++ b/src/Knp/Component/Pager/Paginator.php @@ -87,7 +87,7 @@ public function paginate($target, int $page = 1, ?int $limit = null, array $opti } // before pagination start - $beforeEvent = new Event\BeforeEvent($this->eventDispatcher, $this->argumentAccess, $this->connection); + $beforeEvent = new Event\BeforeEvent($this->eventDispatcher, $this->argumentAccess, $this->connection, $options); $this->eventDispatcher->dispatch($beforeEvent, 'knp_pager.before'); // items $itemsEvent = new Event\ItemsEvent($offset, $limit);