mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-02 22:17:45 +00:00
resolve center in Report Controller
This commit is contained in:
parent
96ddc73e45
commit
fcb057c55b
@ -11,12 +11,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\ReportBundle\Controller;
|
||||
|
||||
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Privacy\PrivacyEvent;
|
||||
use Chill\ReportBundle\Entity\Report;
|
||||
use Chill\ReportBundle\Form\ReportType;
|
||||
use Chill\ReportBundle\Security\Authorization\ReportVoter;
|
||||
use DateTime;
|
||||
use RuntimeException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@ -25,7 +28,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
@ -48,17 +51,25 @@ class ReportController extends AbstractController
|
||||
*/
|
||||
protected $paginator;
|
||||
|
||||
private CenterResolverManagerInterface $centerResolverManager;
|
||||
|
||||
private Security $security;
|
||||
|
||||
/**
|
||||
* ReportController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
PaginatorFactory $paginator
|
||||
PaginatorFactory $paginator,
|
||||
CenterResolverManagerInterface $centerResolverManager,
|
||||
Security $security
|
||||
) {
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->paginator = $paginator;
|
||||
$this->centerResolverManager = $centerResolverManager;
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,9 +229,9 @@ class ReportController extends AbstractController
|
||||
|
||||
$reachableScopes = $this->authorizationHelper
|
||||
->getReachableScopes(
|
||||
$this->getUser(),
|
||||
new Role('CHILL_REPORT_SEE'),
|
||||
$person->getCenter()
|
||||
$this->security->getUser(),
|
||||
ReportVoter::SEE,
|
||||
$this->centerResolverManager->resolveCenters($person)
|
||||
);
|
||||
|
||||
$total = $em
|
||||
@ -578,8 +589,8 @@ class ReportController extends AbstractController
|
||||
),
|
||||
'method' => 'PUT',
|
||||
'cFGroup' => $entity->getCFGroup(),
|
||||
'role' => new Role('CHILL_REPORT_UPDATE'),
|
||||
'center' => $entity->getPerson()->getCenter(),
|
||||
]);
|
||||
'role' => ReportVoter::UPDATE,
|
||||
'center' => $this->centerResolverManager->resolveCenters($entity->getPerson()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
services:
|
||||
Chill\ReportBundle\Controller\ReportController:
|
||||
arguments:
|
||||
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
|
||||
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
||||
$paginator: '@Chill\MainBundle\Pagination\PaginatorFactory'
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags: ['controller.service_arguments']
|
||||
|
Loading…
x
Reference in New Issue
Block a user