inject PaginatorFactory in constructor

This commit is contained in:
Tchama 2020-09-08 18:26:37 +02:00
parent 46293a9baf
commit 0affc534c5

View File

@ -21,6 +21,7 @@
namespace Chill\ReportBundle\Controller; namespace Chill\ReportBundle\Controller;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Privacy\PrivacyEvent; use Chill\PersonBundle\Privacy\PrivacyEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@ -51,16 +52,27 @@ class ReportController extends Controller
*/ */
protected $authorizationHelper; protected $authorizationHelper;
/**
* @var PaginatorFactory
*/
protected $paginator;
/** /**
* ReportController constructor. * ReportController constructor.
* *
* @param EventDispatcherInterface $eventDispatcher * @param EventDispatcherInterface $eventDispatcher
* @param AuthorizationHelper $authorizationHelper * @param AuthorizationHelper $authorizationHelper
* @param PaginatorFactory $paginator
*/ */
public function __construct(EventDispatcherInterface $eventDispatcher, AuthorizationHelper $authorizationHelper) public function __construct(
EventDispatcherInterface $eventDispatcher,
AuthorizationHelper $authorizationHelper,
PaginatorFactory $paginator
)
{ {
$this->eventDispatcher = $eventDispatcher; $this->eventDispatcher = $eventDispatcher;
$this->authorizationHelper = $authorizationHelper; $this->authorizationHelper = $authorizationHelper;
$this->paginator = $paginator;
} }
@ -91,7 +103,7 @@ class ReportController extends Controller
->getSingleScalarResult(); ->getSingleScalarResult();
// get the PaginatorFactory // get the PaginatorFactory
$paginator = $this->get('chill_main.paginator_factory')->create($total); $paginator = $this->paginator->create($total);
$reports = $em->createQuery('SELECT r $reports = $em->createQuery('SELECT r
FROM ChillReportBundle:Report r FROM ChillReportBundle:Report r