mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
renaming some function in paginator + fixing bug in paginator
- the '*itemPerPage' function are renamed '*itemsPerPage' - the paginatorFactory now get the route parameters correctly
This commit is contained in:
@@ -40,7 +40,7 @@ class PaginatorFactory
|
||||
private $itemPerPage;
|
||||
|
||||
/**
|
||||
* the router and generator for url
|
||||
* the router and generator for url
|
||||
*
|
||||
* @var RouterInterface
|
||||
*/
|
||||
@@ -59,8 +59,8 @@ class PaginatorFactory
|
||||
|
||||
|
||||
public function __construct(
|
||||
RequestStack $requestStack,
|
||||
RouterInterface $router,
|
||||
RequestStack $requestStack,
|
||||
RouterInterface $router,
|
||||
$itemPerPage = 50
|
||||
) {
|
||||
$this->itemPerPage = $itemPerPage;
|
||||
@@ -70,27 +70,27 @@ class PaginatorFactory
|
||||
|
||||
/**
|
||||
* create a paginator instance
|
||||
*
|
||||
* The default route and route parameters are the current ones. If set,
|
||||
*
|
||||
* The default route and route parameters are the current ones. If set,
|
||||
* thos route are overriden.
|
||||
*
|
||||
*
|
||||
* @param int $totalItems
|
||||
* @param string|null $route the specific route to use in pages
|
||||
* @param array|null $routeParameters the specific route parameters to use in pages
|
||||
* @return PaginatorInterface
|
||||
*/
|
||||
public function create(
|
||||
$totalItems,
|
||||
$route = null,
|
||||
$totalItems,
|
||||
$route = null,
|
||||
array $routeParameters = null
|
||||
) {
|
||||
|
||||
return new Paginator(
|
||||
$totalItems,
|
||||
$this->getCurrentItemPerPage(),
|
||||
$this->getCurrentItemsPerPage(),
|
||||
$this->getCurrentPageNumber(),
|
||||
$route === null ? $this->getCurrentRoute() : $route,
|
||||
$routeParameters === null ? $this->getCurrentRouteParameters() :
|
||||
$routeParameters === null ? $this->getCurrentRouteParameters() :
|
||||
$routeParameters,
|
||||
$this->router,
|
||||
self::DEFAULT_CURRENT_PAGE_KEY,
|
||||
@@ -98,7 +98,7 @@ class PaginatorFactory
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCurrentPageNumber()
|
||||
@@ -109,7 +109,7 @@ class PaginatorFactory
|
||||
->getInt(self::DEFAULT_CURRENT_PAGE_KEY, self::DEFAULT_PAGE_NUMBER);
|
||||
}
|
||||
|
||||
public function getCurrentItemPerPage()
|
||||
public function getCurrentItemsPerPage()
|
||||
{
|
||||
return $this->requestStack
|
||||
->getCurrentRequest()
|
||||
@@ -119,8 +119,8 @@ class PaginatorFactory
|
||||
|
||||
public function getCurrentPageFirstItemNumber()
|
||||
{
|
||||
return ($this->getCurrentPageNumber() - 1) *
|
||||
$this->getCurrentItemPerPage();
|
||||
return ($this->getCurrentPageNumber() - 1) *
|
||||
$this->getCurrentItemsPerPage();
|
||||
}
|
||||
|
||||
protected function getCurrentRoute()
|
||||
@@ -134,7 +134,13 @@ class PaginatorFactory
|
||||
{
|
||||
return array_merge(
|
||||
$this->router->getContext()->getParameters(),
|
||||
$this->requestStack->getCurrentRequest()
|
||||
->query->all());
|
||||
// get the route parameters
|
||||
$this->requestStack
|
||||
->getCurrentRequest()
|
||||
->attributes->get('_route_params'),
|
||||
// get the query parameters
|
||||
$this->requestStack
|
||||
->getCurrentRequest()->query->all()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user