mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
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.
This commit is contained in:
parent
b11684fb3b
commit
ebdfa04843
@ -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
|
||||
|
@ -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'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user