Add pagination in the findBy()

This commit is contained in:
Julie Lenaerts 2022-02-11 11:25:53 +01:00 committed by Julien Fastré
parent ac33c6aad8
commit d6cc69b919

View File

@ -156,12 +156,15 @@ class DocumentPersonController extends AbstractController
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
$documents = $this->personDocumentACLAwareRepository->findByPerson($person);
// wrong: count documents in database and retrieve document for this page.
$total = $this->personDocumentACLAwareRepository->countByPerson($person);
$pagination = $this->paginatorFactory->create($total);
$documents = $this->personDocumentACLAwareRepository->findByPerson(
$person,
[],
$pagination->getItemsPerPage(),
$pagination->getCurrentPageFirstItemNumber());
$event = new PrivacyEvent($person, [
'element_class' => PersonDocument::class,
'action' => 'index',