mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-22 18:24:23 +00:00
Update authorization helper interface in export classes
Replaced `AuthorizationHelperForCurrentUserInterface` with the more generic `AuthorizationHelperInterface` in tests and export helpers. Adjusted method signatures to include the `User` parameter for scope retrieval. Removed unused `centers` mapping in `ListActivity`.
This commit is contained in:
parent
4206d17345
commit
9a50dad671
@ -118,8 +118,6 @@ final readonly class ListActivity implements ListInterface, GroupedExportInterfa
|
|||||||
|
|
||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data, ExportGenerationContext $context): \Doctrine\ORM\QueryBuilder
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data, ExportGenerationContext $context): \Doctrine\ORM\QueryBuilder
|
||||||
{
|
{
|
||||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
|
||||||
|
|
||||||
$qb = $this->entityManager->createQueryBuilder();
|
$qb = $this->entityManager->createQueryBuilder();
|
||||||
|
|
||||||
$qb
|
$qb
|
||||||
|
@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Export\Helper;
|
|||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Repository\CenterRepositoryInterface;
|
use Chill\MainBundle\Repository\CenterRepositoryInterface;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
|
||||||
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||||
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
|
||||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
@ -30,7 +31,7 @@ final readonly class FilterListAccompanyingPeriodHelper implements FilterListAcc
|
|||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private CenterRepositoryInterface $centerRepository,
|
private CenterRepositoryInterface $centerRepository,
|
||||||
private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser,
|
private AuthorizationHelperInterface $authorizationHelper,
|
||||||
ParameterBagInterface $parameterBag,
|
ParameterBagInterface $parameterBag,
|
||||||
) {
|
) {
|
||||||
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
|
$this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center'];
|
||||||
@ -53,9 +54,9 @@ final readonly class FilterListAccompanyingPeriodHelper implements FilterListAcc
|
|||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($centers as $center) {
|
foreach ($centers as $center) {
|
||||||
$scopes = $this->authorizationHelperForCurrentUser->getReachableScopes(AccompanyingPeriodVoter::SEE_DETAILS, $center);
|
$scopes = $this->authorizationHelper->getReachableScopes($user, AccompanyingPeriodVoter::SEE_DETAILS, $center);
|
||||||
$scopesConfidential =
|
$scopesConfidential =
|
||||||
$this->authorizationHelperForCurrentUser->getReachableScopes(AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, $center);
|
$this->authorizationHelper->getReachableScopes($user, AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, $center);
|
||||||
$orScopes = $qb->expr()->orX();
|
$orScopes = $qb->expr()->orX();
|
||||||
|
|
||||||
foreach ($scopes as $scope) {
|
foreach ($scopes as $scope) {
|
||||||
|
@ -12,9 +12,11 @@ declare(strict_types=1);
|
|||||||
namespace Chill\PersonBundle\Tests\Export\Export;
|
namespace Chill\PersonBundle\Tests\Export\Export;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Repository\CenterRepositoryInterface;
|
use Chill\MainBundle\Repository\CenterRepositoryInterface;
|
||||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
|
||||||
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||||
@ -58,10 +60,10 @@ class ListAccompanyingPeriodTest extends AbstractExportTest
|
|||||||
// mock authorization helper
|
// mock authorization helper
|
||||||
$scopes = $scopeRepository->findAll();
|
$scopes = $scopeRepository->findAll();
|
||||||
$scopesConfidentials = [] !== $scopes ? [$scopes[0]] : [];
|
$scopesConfidentials = [] !== $scopes ? [$scopes[0]] : [];
|
||||||
$authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class);
|
$authorizationHelper = $this->prophesize(AuthorizationHelperInterface::class);
|
||||||
$authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_DETAILS, Argument::type(Center::class))
|
$authorizationHelper->getReachableScopes(Argument::type(User::class), AccompanyingPeriodVoter::SEE_DETAILS, Argument::type(Center::class))
|
||||||
->willReturn($scopes);
|
->willReturn($scopes);
|
||||||
$authorizationHelper->getReachableScopes(AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, Argument::type(Center::class))
|
$authorizationHelper->getReachableScopes(Argument::type(User::class), AccompanyingPeriodVoter::SEE_CONFIDENTIAL_ALL, Argument::type(Center::class))
|
||||||
->willReturn($scopesConfidentials);
|
->willReturn($scopesConfidentials);
|
||||||
|
|
||||||
yield new ListAccompanyingPeriod(
|
yield new ListAccompanyingPeriod(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user