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

fix(PagerFactory): pager should not be lazy, so that if the page does not exist, it will throw an exception immediately, not inside template. #61

Merged
merged 1 commit into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading