mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
fix errors in pagination
This commit is contained in:
@@ -63,6 +63,13 @@ class Page implements PageInterface
|
||||
* @var int
|
||||
*/
|
||||
protected $itemPerPage;
|
||||
|
||||
/**
|
||||
* The number of items in the whole iteration
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $totalItems;
|
||||
|
||||
|
||||
public function __construct(
|
||||
@@ -70,13 +77,15 @@ class Page implements PageInterface
|
||||
$itemPerPage,
|
||||
UrlGeneratorInterface $urlGenerator,
|
||||
$route,
|
||||
array $routeParameters
|
||||
array $routeParameters,
|
||||
$totalItems
|
||||
) {
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->number = $number;
|
||||
$this->itemPerPage = $itemPerPage;
|
||||
$this->route = $route;
|
||||
$this->routeParameters = $routeParameters;
|
||||
$this->totalItems = $totalItems;
|
||||
}
|
||||
|
||||
public function generateUrl()
|
||||
@@ -91,7 +100,9 @@ class Page implements PageInterface
|
||||
|
||||
public function getLastItemNumber()
|
||||
{
|
||||
return $this->number * $this->itemPerPage - 1;
|
||||
$last = $this->number * $this->itemPerPage - 1;
|
||||
|
||||
return $last < $this->totalItems ? $last : $this->totalItems;
|
||||
}
|
||||
|
||||
public function getNumber()
|
||||
|
Reference in New Issue
Block a user