From d86b86487fd0d4891484d086a653cbf9364d36b9 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 31 Aug 2022 15:27:03 +0200 Subject: [PATCH] fix some remarks in 111_export review --- .../Export/Filter/BetweenDatesFilter.php | 4 ++-- .../ChildrenNumberAggregator.php | 11 +++++++++++ .../SocialWorkAggregators/ActionTypeAggregator.php | 13 +++++++------ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php index ff7e61189..b720eb3db 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php +++ b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php @@ -59,9 +59,9 @@ class BetweenDatesFilter implements FilterInterface } $qb->add('where', $where); - $qb->setParameter('dateFrom', $data['date_from']); + $qb->setParameter('dateFrom', $data['date_from'], Types::DATE_MUTABLE); // modify dateTo so that entire day is also taken into account up until the beginning of the next day. - $qb->setParameter('dateTo', $data['date_to']->modify('+1 day')); + $qb->setParameter('dateTo', $data['date_to']->modify('+1 day'), Types::DATE_MUTABLE); } public function applyOn(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php index df50b76f0..bcfbee023 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php @@ -5,6 +5,8 @@ namespace Chill\PersonBundle\Export\Aggregator\HouseholdAggregators; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Form\Type\ChillDateType; use Chill\PersonBundle\Export\Declarations; +use Doctrine\DBAL\Types\Types; +use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -100,6 +102,15 @@ class ChildrenNumberAggregator implements AggregatorInterface $qb->expr()->isNull('composition.endDate') ) ); + + if ($where instanceof Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } + + $qb->add('where', $where); + $qb->setParameter('ondate', $data['on_date'], Types::DATE_MUTABLE); } /** diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php index d8f485561..c975184af 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php @@ -15,6 +15,7 @@ use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository; +use Chill\PersonBundle\Templating\Entity\SocialActionRender; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -22,12 +23,13 @@ final class ActionTypeAggregator implements AggregatorInterface { private SocialActionRepository $socialActionRepository; - private TranslatableStringHelper $translatableStringHelper; + private SocialActionRender $actionRender; - public function __construct(SocialActionRepository $socialActionRepository, TranslatableStringHelper $translatableStringHelper) - { + public function __construct( + SocialActionRepository $socialActionRepository, + SocialActionRender $actionRender + ) { $this->socialActionRepository = $socialActionRepository; - $this->translatableStringHelper = $translatableStringHelper; } public function addRole() @@ -62,7 +64,6 @@ final class ActionTypeAggregator implements AggregatorInterface public function getLabels($key, array $values, $data) { - //TODO certain social actions have the same title as other, but are linked to different social issues, should we make a visual distinction? return function ($value): string { if ('_header' === $value) { return 'Social Action Type'; @@ -70,7 +71,7 @@ final class ActionTypeAggregator implements AggregatorInterface $sa = $this->socialActionRepository->find($value); - return $this->translatableStringHelper->localize($sa->getTitle()); + return $this->actionRender->renderString($sa, []); }; }