Refactor scope condition logic in FilterListAccompanyingPeriodHelper

Replaced inline string interpolation with `sprintf` for scope conditions and added user-based condition handling. Introduced new user-specific parameters to enhance query flexibility. Removed unused `AuthorizationHelperForCurrentUserInterface` import.
This commit is contained in:
Julien Fastré 2025-06-17 16:05:56 +02:00
parent 9a50dad671
commit 00350b9efc
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -13,7 +13,6 @@ namespace Chill\PersonBundle\Export\Helper;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Repository\CenterRepositoryInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
@ -61,15 +60,16 @@ final readonly class FilterListAccompanyingPeriodHelper implements FilterListAcc
foreach ($scopes as $scope) {
$scopeCondition = match (in_array($scope, $scopesConfidential, true)) {
true => ":scope_{$i} MEMBER OF acp.scopes",
true => sprintf(':scope_%s MEMBER OF acp.scopes', $i),
false => $qb->expr()->andX(
'acp.confidential = FALSE',
":scope_{$i} MEMBER OF acp.scopes",
sprintf(':scope_%s MEMBER OF acp.scopes', $i),
),
};
$orScopes->add($scopeCondition);
$orScopes->add($qb->expr()->orX(sprintf('acp.user = :user_%d', $i), $scopeCondition));
$qb->setParameter("scope_{$i}", $scope);
$qb->setParameter("user_{$i}", $user);
++$i;
}