From 53ea299890a77cf9d6ae3f0e45cc62a89618f303 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo <1102197+priyadi@users.noreply.github.com> Date: Sat, 8 Jun 2024 13:17:17 +0700 Subject: [PATCH] fix(`PagerFactory`): pager should not be lazy, so that if the page does not exist, it will throw an exception immediately, not inside template. --- CHANGELOG.md | 5 +++++ packages/rekapager-bundle/src/PagerFactory.php | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a58d3c..e5179cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +# 0.9.2 + +* fix(`PagerFactory`): pager should not be lazy, so that if the page does not + exist, it will throw an exception immediately, not inside template. + # 0.9.1 * fix(`QueryBuilderAdapter`): use generated field names for our boundary fields diff --git a/packages/rekapager-bundle/src/PagerFactory.php b/packages/rekapager-bundle/src/PagerFactory.php index b6061eb..5f6caa2 100644 --- a/packages/rekapager-bundle/src/PagerFactory.php +++ b/packages/rekapager-bundle/src/PagerFactory.php @@ -96,7 +96,6 @@ public function createPager( $queryParams = $request->query->all(); $routeParams = array_merge($queryParams, $routeParams); - /** @var array $routeParams */ $pageUrlGenerator = $this->pageUrlGeneratorFactory->createPageUrlGenerator( @@ -106,13 +105,17 @@ public function createPager( routeParams: $routeParams ); - return new Pager( + $pager = new Pager( page: $page, proximity: $proximity, pageLimit: $pageLimit, pageUrlGenerator: $pageUrlGenerator, pageIdentifierEncoderLocator: $this->pageIdentifierEncoderLocator, ); + + foreach ($pager->getCurrentPage() as $i); + + return $pager; } /**