-
Notifications
You must be signed in to change notification settings - Fork 141
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 ArgumentAccess
with the knp_pager.items
event
#343
Conversation
08e5ca6
to
5cd777b
Compare
This makes it possible for `knp_pager.items` event subscribers to access the pagination parameters, without having to be wired up by a dedicated `knp_pager.before` handler.
5cd777b
to
6756cda
Compare
$requestStack = $this->createRequestStack(['filterParam' => ['a.id', 'a.title'], 'filterValue' => '*er']); | ||
$accessor = new RequestArgumentAccess($requestStack); | ||
$p = new Paginator($dispatcher, $accessor); | ||
$view = $p->paginate($query, 1, 10); | ||
$items = $view->getItems(); | ||
$this->assertCount(2, $items); | ||
$this->assertEquals('summer', $items[0]->getTitle()); | ||
$this->assertEquals('winter', $items[1]->getTitle()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test code never did what it was supposed to do – test a filterParam
that is an array.
In fact, the FiltrationSubscriber
would add the ORM\QuerySubscriber
only on the first pass, and so we were always using (without noticing) the first RequestArgumentAccess
instance where the filterParam
is a scalar value.
In fact, the Symfony Request
throws when trying to access a query parameter value that is not a scalar, as it was the case in this removed code.
a9f5b89
to
a5977de
Compare
tests/Test/Pager/Subscriber/Filtration/Doctrine/ORM/QueryTest.php
Outdated
Show resolved
Hide resolved
@garak thank you for your feedback! I've addressed the objections. |
This makes it possible for
knp_pager.items
event subscribers to access the pagination parameters, without having to be wired up by a dedicatedknp_pager.before
handler.