Skip to content

Commit

Permalink
Do not set last page to 0 when there is no results (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Mar 29, 2022
1 parent 7ab70a5 commit 7e0dad7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Datagrid/Pager.php
Expand Up @@ -59,8 +59,10 @@ public function init(): void
$query->setFirstResult(0);
$query->setMaxResults(0);

if (0 === $this->getPage() || 0 === $this->getMaxPerPage() || 0 === $this->countResults()) {
if (0 === $this->getPage() || 0 === $this->getMaxPerPage()) {
$this->setLastPage(0);
} elseif (0 === $this->countResults()) {
$this->setLastPage(1);
} else {
$offset = ($this->getPage() - 1) * $this->getMaxPerPage();

Expand Down

0 comments on commit 7e0dad7

Please sign in to comment.