diff --git a/src/Knp/Component/Pager/Event/BeforeEvent.php b/src/Knp/Component/Pager/Event/BeforeEvent.php index bddd7b03..88e22db8 100644 --- a/src/Knp/Component/Pager/Event/BeforeEvent.php +++ b/src/Knp/Component/Pager/Event/BeforeEvent.php @@ -12,11 +12,15 @@ */ final class BeforeEvent extends Event { + /** + * @var array + */ + public array $options = []; + public function __construct( private readonly EventDispatcherInterface $eventDispatcher, private readonly ArgumentAccessInterface $argumentAccess, private readonly ?Connection $connection = null, - private array &$options = [], ) { } @@ -30,11 +34,6 @@ 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 cc57a1eb..c7dd3918 100644 --- a/src/Knp/Component/Pager/Paginator.php +++ b/src/Knp/Component/Pager/Paginator.php @@ -87,7 +87,8 @@ 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, $options); + $beforeEvent = new Event\BeforeEvent($this->eventDispatcher, $this->argumentAccess, $this->connection); + $beforeEvent->options =& $options; $this->eventDispatcher->dispatch($beforeEvent, 'knp_pager.before'); // items $itemsEvent = new Event\ItemsEvent($offset, $limit);