fix errors in pagination

This commit is contained in:
2019-10-25 14:35:34 +02:00
parent 517ea1de31
commit f23aec0649
3 changed files with 20 additions and 3 deletions

View File

@@ -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()