From ebdfa04843402a05f4f3caed0169644768e32093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 25 Apr 2025 21:04:30 +0200 Subject: [PATCH] Refactor user handling in filters for consistency Updated `UserWorkingOnCourseFilter` and `ReferrerFilter` to ensure consistent handling of users via `userOrMe` methods. Also adjusted normalization/denormalization to align with these changes, enhancing readability and maintainability. --- .../Filter/AccompanyingCourseFilters/ReferrerFilter.php | 8 ++++---- .../UserWorkingOnCourseFilter.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php index b00cd6b46..5a059e908 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php @@ -26,7 +26,7 @@ final readonly class ReferrerFilter implements FilterInterface { use \Chill\MainBundle\Export\ExportDataNormalizerTrait; - private const A = 'acp_referrer_filter_uhistory'; + private const A = 'acp_referrer_filter_uhistory_x'; private const P = 'acp_referrer_filter_date'; @@ -55,7 +55,7 @@ final readonly class ReferrerFilter implements FilterInterface ->andWhere( $qb->expr()->in(self::A.'.user', ':'.self::PU) ) - ->setParameter(self::PU, $data['accepted_referrers']) + ->setParameter(self::PU, $this->userOrMe($data['accepted_referrers'], $exportGenerationContext)) ->setParameter( self::P, $this->rollingDateConverter->convert($data['date_calc']) @@ -86,12 +86,12 @@ final readonly class ReferrerFilter implements FilterInterface public function normalizeFormData(array $formData): array { - return ['accepted_referrers' => $this->normalizeDoctrineEntity($formData['accepted_referrers']), 'date_calc' => $formData['date_calc']->normalize()]; + return ['accepted_referrers' => $this->normalizeUserOrMe($formData['accepted_referrers']), 'date_calc' => $formData['date_calc']->normalize()]; } public function denormalizeFormData(array $formData, int $fromVersion): array { - return ['accepted_referrers' => $this->denormalizeDoctrineEntity($formData['accepted_referrers'], $this->userRepository), 'date_calc' => RollingDate::fromNormalized($formData['date_calc'])]; + return ['accepted_referrers' => $this->denormalizeUserOrMe($formData['accepted_referrers'], $this->userRepository), 'date_calc' => RollingDate::fromNormalized($formData['date_calc'])]; } public function getFormDefaultData(): array diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php index c9ff7adcb..3a65d97d5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserWorkingOnCourseFilter.php @@ -92,8 +92,8 @@ final readonly class UserWorkingOnCourseFilter implements FilterInterface '%users%' => implode( ', ', array_map( - fn (User $u) => $this->userRender->renderString($this->userOrMe($u, $context), []), - $data['users'] instanceof Collection ? $data['users']->toArray() : $data['users'] + fn (User $u) => $this->userRender->renderString($u, []), + $this->userOrMe($data['users'], $context) ) ), '%start_date%' => $this->rollingDateConverter->convert($data['start_date'])?->format('d-m-Y'),