Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass $options in knp_pager.before event #342

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -12,10 +12,11 @@
*/
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 = [],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need to pass this argument by reference?

) {
}

Expand All @@ -29,6 +30,11 @@
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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same objection about reference here

{
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