mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
delegates the acl for fetching person documents to an ACLAwareREpository
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Chill\DocStoreBundle\Controller;
|
||||
|
||||
use Chill\DocStoreBundle\Entity\PersonDocument;
|
||||
use Chill\DocStoreBundle\Form\PersonDocumentType;
|
||||
use Chill\DocStoreBundle\Repository\PersonDocumentACLAwareRepositoryInterface;
|
||||
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
@@ -44,6 +45,8 @@ class DocumentPersonController extends AbstractController
|
||||
|
||||
private PaginatorFactory $paginatorFactory;
|
||||
|
||||
private PersonDocumentACLAwareRepositoryInterface $personDocumentACLAwareRepository;
|
||||
|
||||
/**
|
||||
* DocumentPersonController constructor.
|
||||
*/
|
||||
@@ -51,12 +54,14 @@ class DocumentPersonController extends AbstractController
|
||||
TranslatorInterface $translator,
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
PaginatorFactory $paginatorFactory
|
||||
PaginatorFactory $paginatorFactory,
|
||||
PersonDocumentACLAwareRepositoryInterface $personDocumentACLAwareRepository
|
||||
) {
|
||||
$this->translator = $translator;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->paginatorFactory = $paginatorFactory;
|
||||
$this->personDocumentACLAwareRepository = $personDocumentACLAwareRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,21 +157,10 @@ class DocumentPersonController extends AbstractController
|
||||
|
||||
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
|
||||
|
||||
$reachableScopes = $this->authorizationHelper
|
||||
->getReachableScopes(
|
||||
$this->getUser(),
|
||||
PersonDocumentVoter::SEE,
|
||||
$person->getCenter()
|
||||
);
|
||||
$documents = $this->personDocumentACLAwareRepository->findByPerson($person);
|
||||
|
||||
$documents = $em
|
||||
->getRepository('ChillDocStoreBundle:PersonDocument')
|
||||
->findBy(
|
||||
['person' => $person, 'scope' => $reachableScopes],
|
||||
['date' => 'DESC']
|
||||
);
|
||||
|
||||
$total = count($documents);
|
||||
// wrong: count documents in database and retrieve document for this page.
|
||||
$total = $this->personDocumentACLAwareRepository->countByPerson($person);
|
||||
$pagination = $this->paginatorFactory->create($total);
|
||||
|
||||
$event = new PrivacyEvent($person, [
|
||||
|
Reference in New Issue
Block a user