mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'cherry-pick-43702ded' into 'master'
fix pagination problems See merge request Chill-Projet/chill-bundles!252
This commit is contained in:
commit
5645cb0cdd
@ -109,6 +109,10 @@ class Paginator implements PaginatorInterface
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (0 === $this->totalItems) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
$nb = floor($this->totalItems / $this->itemPerPage);
|
$nb = floor($this->totalItems / $this->itemPerPage);
|
||||||
|
|
||||||
if ($this->totalItems % $this->itemPerPage > 0) {
|
if ($this->totalItems % $this->itemPerPage > 0) {
|
||||||
@ -211,6 +215,10 @@ class Paginator implements PaginatorInterface
|
|||||||
|
|
||||||
public function hasPage($number)
|
public function hasPage($number)
|
||||||
{
|
{
|
||||||
|
if (0 === $this->totalItems) {
|
||||||
|
return 1 === $number;
|
||||||
|
}
|
||||||
|
|
||||||
return 0 < $number
|
return 0 < $number
|
||||||
&& $this->countPages() >= $number;
|
&& $this->countPages() >= $number;
|
||||||
}
|
}
|
||||||
|
@ -204,6 +204,14 @@ final class PaginatorTest extends KernelTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPagesWithoutResult()
|
||||||
|
{
|
||||||
|
$paginator = $this->generatePaginator(0, 10);
|
||||||
|
|
||||||
|
$this->assertEquals(0, $paginator->getCurrentPageFirstItemNumber());
|
||||||
|
$this->assertEquals(10, $paginator->getItemsPerPage());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $itemPerPage
|
* @param int $itemPerPage
|
||||||
* @param string $route
|
* @param string $route
|
||||||
|
Loading…
x
Reference in New Issue
Block a user