Skip to content

Commit

Permalink
Pass $options in knp_pager.before event
Browse files Browse the repository at this point in the history
  • Loading branch information
mpdude committed Sep 20, 2024
1 parent 1dbd333 commit 226ea4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Knp/Component/Pager/Event/BeforeEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ final class BeforeEvent extends Event
public function __construct(

Check failure on line 15 in src/Knp/Component/Pager/Event/BeforeEvent.php

View workflow job for this annotation

GitHub Actions / PHPStan

Method Knp\Component\Pager\Event\BeforeEvent::__construct() has parameter $options with no value type specified in iterable type array.
private readonly EventDispatcherInterface $eventDispatcher,
private readonly ArgumentAccessInterface $argumentAccess,
private readonly ?Connection $connection = null
private readonly ?Connection $connection = null,
private array &$options = [],
) {
}

Expand All @@ -29,6 +30,11 @@ public function getArgumentAccess(): ArgumentAccessInterface
return $this->argumentAccess;
}

public function &getOptions(): array

Check failure on line 33 in src/Knp/Component/Pager/Event/BeforeEvent.php

View workflow job for this annotation

GitHub Actions / PHPStan

Method Knp\Component\Pager\Event\BeforeEvent::getOptions() return type has no value type specified in iterable type array.
{
return $this->options;
}

public function getConnection(): ?Connection
{
return $this->connection;
Expand Down
2 changes: 1 addition & 1 deletion src/Knp/Component/Pager/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 226ea4b

Please sign in to comment.