From 48da6d0a92920a2c5128d9e78b7f7e1e35ca77e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 7 Nov 2022 21:11:20 +0100 Subject: [PATCH] Feature: Apply rolling date on StepAggregator --- .../StepAggregator.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php index fc2fcc7b2..e17e9f9a5 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php @@ -12,10 +12,11 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators; use Chill\MainBundle\Export\AggregatorInterface; -use Chill\MainBundle\Form\Type\ChillDateType; +use Chill\MainBundle\Form\Type\PickRollingDateType; +use Chill\MainBundle\Service\RollingDate\RollingDate; +use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Export\Declarations; -use DateTime; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -27,11 +28,15 @@ final class StepAggregator implements AggregatorInterface private const P = 'acp_step_agg_date'; + private RollingDateConverterInterface $rollingDateConverter; + private TranslatorInterface $translator; public function __construct( + RollingDateConverterInterface $rollingDateConverter, TranslatorInterface $translator ) { + $this->rollingDateConverter = $rollingDateConverter; $this->translator = $translator; } @@ -60,7 +65,7 @@ final class StepAggregator implements AggregatorInterface ) ) ) - ->setParameter(self::P, $data['on_date']) + ->setParameter(self::P, $this->rollingDateConverter->convert($data['on_date'])) ->addGroupBy('step_aggregator'); } @@ -71,8 +76,8 @@ final class StepAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { - $builder->add('on_date', ChillDateType::class, [ - 'data' => new DateTime(), + $builder->add('on_date', PickRollingDateType::class, [ + 'data' => new RollingDate(RollingDate::T_TODAY), ]); }