mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-06 14:54:57 +00:00
DX: apply rector rules up to php8.0
This commit is contained in:
@@ -48,20 +48,11 @@ class ChillPaginationTwig extends AbstractExtension
|
||||
PaginatorInterface $paginator,
|
||||
$template = '@ChillMain/Pagination/long.html.twig'
|
||||
) {
|
||||
switch ($template) {
|
||||
case 'long':
|
||||
$t = self::LONG_TEMPLATE;
|
||||
|
||||
break;
|
||||
|
||||
case 'short':
|
||||
$t = self::SHORT_TEMPLATE;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$t = $template;
|
||||
}
|
||||
$t = match ($template) {
|
||||
'long' => self::LONG_TEMPLATE,
|
||||
'short' => self::SHORT_TEMPLATE,
|
||||
default => $template,
|
||||
};
|
||||
|
||||
return $env->render($t, [
|
||||
'paginator' => $paginator,
|
||||
|
@@ -18,59 +18,36 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
*/
|
||||
class Page implements PageInterface
|
||||
{
|
||||
/**
|
||||
* the number of item per page.
|
||||
*
|
||||
*/
|
||||
protected int $itemPerPage;
|
||||
|
||||
/**
|
||||
* the number of the current page.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected int $number;
|
||||
|
||||
/**
|
||||
* The route for the current page.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected string $route;
|
||||
|
||||
/**
|
||||
* Parameters for the route to the current page.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected array $routeParameters;
|
||||
|
||||
/**
|
||||
* The number of items in the whole iteration.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected int $totalItems;
|
||||
|
||||
/**
|
||||
* @var UrlGeneratorInterface
|
||||
*/
|
||||
protected $urlGenerator;
|
||||
|
||||
public function __construct(
|
||||
int $number,
|
||||
int $itemPerPage,
|
||||
/**
|
||||
* the number of the current page.
|
||||
*/
|
||||
protected int $number,
|
||||
/**
|
||||
* the number of item per page.
|
||||
*
|
||||
*/
|
||||
protected int $itemPerPage,
|
||||
UrlGeneratorInterface $urlGenerator,
|
||||
string $route,
|
||||
array $routeParameters,
|
||||
int $totalItems
|
||||
/**
|
||||
* The route for the current page.
|
||||
*/
|
||||
protected string $route,
|
||||
/**
|
||||
* Parameters for the route to the current page.
|
||||
*/
|
||||
protected array $routeParameters,
|
||||
/**
|
||||
* The number of items in the whole iteration.
|
||||
*/
|
||||
protected int $totalItems
|
||||
) {
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->number = $number;
|
||||
$this->itemPerPage = $itemPerPage;
|
||||
$this->route = $route;
|
||||
$this->routeParameters = $routeParameters;
|
||||
$this->totalItems = $totalItems;
|
||||
}
|
||||
|
||||
public function generateUrl(): string
|
||||
|
@@ -20,11 +20,8 @@ class PageGenerator implements Iterator
|
||||
{
|
||||
protected int $current = 1;
|
||||
|
||||
protected Paginator $paginator;
|
||||
|
||||
public function __construct(Paginator $paginator)
|
||||
public function __construct(protected Paginator $paginator)
|
||||
{
|
||||
$this->paginator = $paginator;
|
||||
}
|
||||
|
||||
public function current(): Page
|
||||
|
@@ -22,80 +22,43 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
class Paginator implements PaginatorInterface
|
||||
{
|
||||
/**
|
||||
* The number of the current page.
|
||||
*
|
||||
* @var int
|
||||
* @param string[] $routeParameters
|
||||
*/
|
||||
protected int $currentPageNumber;
|
||||
|
||||
/**
|
||||
* the number of items on a single page.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected int $itemPerPage;
|
||||
|
||||
/**
|
||||
* the key in the GET parameter to indicate the number of item per page.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected string $itemPerPageKey;
|
||||
|
||||
/**
|
||||
* the key in the GET parameter to indicate the page number in
|
||||
* generated routes.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected string $pageKey;
|
||||
|
||||
/**
|
||||
* the route of the pages.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected string $route;
|
||||
|
||||
/**
|
||||
* the parameters of the route.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected array $routeParameters;
|
||||
|
||||
/**
|
||||
* The number of total items.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected int $totalItems;
|
||||
|
||||
/**
|
||||
* the generator for url.
|
||||
*
|
||||
* @var UrlGeneratorInterface
|
||||
*/
|
||||
protected UrlGeneratorInterface $urlGenerator;
|
||||
|
||||
public function __construct(
|
||||
int $totalItems,
|
||||
int $itemPerPage,
|
||||
int $currentPageNumber,
|
||||
string $route,
|
||||
array $routeParameters,
|
||||
UrlGeneratorInterface $urlGenerator,
|
||||
string $pageKey,
|
||||
string $itemPerPageKey
|
||||
/**
|
||||
* The number of total items.
|
||||
*/
|
||||
protected int $totalItems,
|
||||
/**
|
||||
* the number of items on a single page.
|
||||
*/
|
||||
protected int $itemPerPage,
|
||||
/**
|
||||
* The number of the current page.
|
||||
*/
|
||||
protected int $currentPageNumber,
|
||||
/**
|
||||
* the route of the pages.
|
||||
*/
|
||||
protected string $route,
|
||||
/**
|
||||
* the parameters of the route.
|
||||
*/
|
||||
protected array $routeParameters,
|
||||
/**
|
||||
* the generator for url.
|
||||
*/
|
||||
protected UrlGeneratorInterface $urlGenerator,
|
||||
/**
|
||||
* the key in the GET parameter to indicate the page number in
|
||||
* generated routes.
|
||||
*/
|
||||
protected string $pageKey,
|
||||
/**
|
||||
* the key in the GET parameter to indicate the number of item per page.
|
||||
*/
|
||||
protected string $itemPerPageKey
|
||||
) {
|
||||
$this->totalItems = $totalItems;
|
||||
$this->itemPerPage = $itemPerPage;
|
||||
$this->currentPageNumber = $currentPageNumber;
|
||||
$this->route = $route;
|
||||
$this->routeParameters = $routeParameters;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->pageKey = $pageKey;
|
||||
$this->itemPerPageKey = $itemPerPageKey;
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
|
@@ -26,35 +26,23 @@ class PaginatorFactory
|
||||
public const DEFAULT_PAGE_NUMBER = 1;
|
||||
|
||||
/**
|
||||
* the default item per page. This may be overriden by
|
||||
* the request or inside the paginator.
|
||||
*
|
||||
* @var int
|
||||
* @param int $itemPerPage
|
||||
*/
|
||||
private $itemPerPage;
|
||||
|
||||
/**
|
||||
* the request stack.
|
||||
*
|
||||
* @var RequestStack
|
||||
*/
|
||||
private $requestStack;
|
||||
|
||||
/**
|
||||
* the router and generator for url.
|
||||
*
|
||||
* @var RouterInterface
|
||||
*/
|
||||
private $router;
|
||||
|
||||
public function __construct(
|
||||
RequestStack $requestStack,
|
||||
RouterInterface $router,
|
||||
$itemPerPage = 20
|
||||
/**
|
||||
* the request stack.
|
||||
*/
|
||||
private RequestStack $requestStack,
|
||||
/**
|
||||
* the router and generator for url.
|
||||
*/
|
||||
private RouterInterface $router,
|
||||
/**
|
||||
* the default item per page. This may be overriden by
|
||||
* the request or inside the paginator.
|
||||
*/
|
||||
private $itemPerPage = 20
|
||||
) {
|
||||
$this->itemPerPage = $itemPerPage;
|
||||
$this->requestStack = $requestStack;
|
||||
$this->router = $router;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +59,7 @@ class PaginatorFactory
|
||||
*/
|
||||
public function create(
|
||||
$totalItems,
|
||||
$route = null,
|
||||
?string $route = null,
|
||||
?array $routeParameters = null
|
||||
) {
|
||||
return new Paginator(
|
||||
|
Reference in New Issue
Block a user