From 00350b9efc3f71b6df00ea41d507436fda67e81d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 17 Jun 2025 16:05:56 +0200 Subject: [PATCH] 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. --- .../Export/Helper/FilterListAccompanyingPeriodHelper.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/FilterListAccompanyingPeriodHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/FilterListAccompanyingPeriodHelper.php index 87426b16a..e631051a0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/FilterListAccompanyingPeriodHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/FilterListAccompanyingPeriodHelper.php @@ -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; }