Skip to content

Commit

Permalink
allows to set the page limit from knp settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Renaud Bredy committed Oct 28, 2022
1 parent 139017c commit ef15622
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Grid/GridBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\ORM\QueryBuilder;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;

Expand All @@ -14,7 +15,7 @@ class GridBuilder
private QueryBuilder $queryBuilder;
private ?Request $request;
private ?FormInterface $filtersForm;
private int $itemsPerPage = 10;
private int $itemsPerPage;

/**
* @var array|Column[]
Expand All @@ -29,9 +30,10 @@ class GridBuilder

private ?Grid $grid;

public function __construct(PaginatorInterface $paginator)
public function __construct(PaginatorInterface $paginator, ParameterBagInterface $params)
{
$this->paginator = $paginator;
$this->itemsPerPage = $params->get('knp_paginator.page_limit') ?? 10;
}

public function create(QueryBuilder $queryBuilder, Request $request, FormInterface $filtersForm = null): self
Expand Down

0 comments on commit ef15622

Please sign in to comment.