mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix errors in pagination
This commit is contained in:
parent
517ea1de31
commit
f23aec0649
@ -80,3 +80,8 @@ Version 1.5.13
|
||||
|
||||
- allow to customize logo on login screen and main layout ;
|
||||
- remove desert background image on page, handle it from cache in login screen;
|
||||
|
||||
Master branch
|
||||
=============
|
||||
|
||||
- fix errors in pagination
|
||||
|
@ -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()
|
||||
|
@ -232,7 +232,8 @@ class Paginator implements PaginatorInterface
|
||||
array_merge($this->routeParameters, array(
|
||||
$this->pageKey => $number,
|
||||
$this->itemPerPageKey => $this->itemPerPage
|
||||
))
|
||||
)),
|
||||
$this->totalItems
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user