Pagination added

This commit is contained in:
2022-02-09 15:10:04 +01:00
committed by Julien Fastré
parent 4304baeca5
commit e0c7daf3fd
5 changed files with 30 additions and 90 deletions

View File

@@ -14,6 +14,7 @@ namespace Chill\DocStoreBundle\Controller;
use Chill\DocStoreBundle\Entity\PersonDocument;
use Chill\DocStoreBundle\Form\PersonDocumentType;
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Privacy\PrivacyEvent;
@@ -35,20 +36,13 @@ use Symfony\Component\Translation\TranslatorInterface;
*/
class DocumentPersonController extends AbstractController
{
/**
* @var AuthorizationHelper
*/
protected $authorizationHelper;
protected AuthorizationHelper $authorizationHelper;
/**
* @var EventDispatcherInterface
*/
protected $eventDispatcher;
protected EventDispatcherInterface $eventDispatcher;
/**
* @var TranslatorInterface
*/
protected $translator;
protected TranslatorInterface $translator;
private PaginatorFactory $paginatorFactory;
/**
* DocumentPersonController constructor.
@@ -56,11 +50,13 @@ class DocumentPersonController extends AbstractController
public function __construct(
TranslatorInterface $translator,
EventDispatcherInterface $eventDispatcher,
AuthorizationHelper $authorizationHelper
AuthorizationHelper $authorizationHelper,
PaginatorFactory $paginatorFactory
) {
$this->translator = $translator;
$this->eventDispatcher = $eventDispatcher;
$this->authorizationHelper = $authorizationHelper;
$this->paginatorFactory = $paginatorFactory;
}
/**
@@ -170,6 +166,9 @@ class DocumentPersonController extends AbstractController
['date' => 'DESC']
);
$total = count($documents);
$pagination = $this->paginatorFactory->create($total);
$event = new PrivacyEvent($person, [
'element_class' => PersonDocument::class,
'action' => 'index',
@@ -181,6 +180,7 @@ class DocumentPersonController extends AbstractController
[
'documents' => $documents,
'person' => $person,
'pagination' => $pagination
]
);
}