Skip to content

Commit ea6bdd3

Browse files
authored
Merge pull request #28 from CauanCabral/master
Update how paging request attribute are defined
2 parents be6342a + d090422 commit ea6bdd3

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

config/bootstrap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
EventManager::instance()->on('Controller.initialize', function ($event) {
1010
$controller = $event->getSubject();
1111
$controller->getEventManager()->on('Service.afterPaginate', function ($event) use ($controller) {
12-
$event->getSubject()->addPagingParamToRequest($controller->request);
12+
$controller->setRequest($event->getSubject()->addPagingParamToRequest($controller->getRequest()));
1313
});
1414
});

src/Service/ServicePaginatorTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,6 @@ public function paginate($object, array $params = [], array $settings = [])
115115
*/
116116
public function addPagingParamToRequest(ServerRequest $request): ServerRequest
117117
{
118-
return $request->withParam('paging', $this->getPaginator()->getPagingParams() + (array)$request->getParam('paging'));
118+
return $request->withAttribute('paging', $this->getPaginator()->getPagingParams() + $request->getAttribute('paging', []));
119119
}
120120
}

tests/TestCase/Service/PaginationServiceTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testPaginate()
4949
$result = $service->paginate($articles);
5050
$request = $service->addPagingParamToRequest($request);
5151

52-
$params = $request->getParam('paging');
52+
$params = $request->getAttribute('paging');
5353
$expected = [
5454
'Articles' => [
5555
'finder' => 'all',

0 commit comments

Comments
 (0)