Skip to content

Commit

Permalink
fix(PagerFactory): pager should not be lazy, so that if the page do…
Browse files Browse the repository at this point in the history
…es not exist, it will throw an exception immediately, not inside template.
  • Loading branch information
priyadi committed Jun 8, 2024
1 parent eab44de commit e1d2554
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# 0.9.2

* build: limit `zenstruck/foundry` to 1.37.* for now
* 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

Expand Down
7 changes: 5 additions & 2 deletions packages/rekapager-bundle/src/PagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public function createPager(
$queryParams = $request->query->all();
$routeParams = array_merge($queryParams, $routeParams);


/** @var array<string,string|int> $routeParams */

$pageUrlGenerator = $this->pageUrlGeneratorFactory->createPageUrlGenerator(
Expand All @@ -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;
}

/**
Expand Down

0 comments on commit e1d2554

Please sign in to comment.