mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-28 09:34:59 +00:00
chill-bundles#25: replace ChillDateType by PickRollingDateType
batch/serial replacing untested
This commit is contained in:
@@ -12,10 +12,10 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Export\Aggregator\HouseholdAggregators;
|
||||
|
||||
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\Export\Declarations;
|
||||
use DateTime;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Query\Expr;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -26,10 +26,14 @@ class ChildrenNumberAggregator implements AggregatorInterface
|
||||
{
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
private RollingDateConverterInterface $rollingDateConverter;
|
||||
|
||||
public function __construct(
|
||||
TranslatorInterface $translator
|
||||
TranslatorInterface $translator,
|
||||
RollingDateConverterInterface $rollingDateConverter
|
||||
) {
|
||||
$this->translator = $translator;
|
||||
$this->rollingDateConverter = $rollingDateConverter;
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
@@ -55,7 +59,9 @@ class ChildrenNumberAggregator implements AggregatorInterface
|
||||
->addSelect('composition_children.numberOfChildren AS childrennumber_aggregator')
|
||||
->addGroupBy('childrennumber_aggregator');
|
||||
|
||||
$qb->setParameter('ondate_composition_children', $data['on_date'], Types::DATE_MUTABLE);
|
||||
$qb->setParameter('ondate_composition_children',
|
||||
$this->rollingDateConverter->convert($data['on_date'])
|
||||
);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@@ -65,8 +71,8 @@ class ChildrenNumberAggregator implements AggregatorInterface
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('on_date', ChillDateType::class, [
|
||||
'data' => new DateTime('now'),
|
||||
$builder->add('on_date', PickRollingDateType::class, [
|
||||
'data' => new RollingDate(RollingDate::T_TODAY),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -12,12 +12,12 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Export\Aggregator\HouseholdAggregators;
|
||||
|
||||
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\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Repository\Household\HouseholdCompositionTypeRepository;
|
||||
use DateTime;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Query\Expr;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -29,12 +29,16 @@ class CompositionAggregator implements AggregatorInterface
|
||||
|
||||
private HouseholdCompositionTypeRepository $typeRepository;
|
||||
|
||||
private RollingDateConverterInterface $rollingDateConverter;
|
||||
|
||||
public function __construct(
|
||||
HouseholdCompositionTypeRepository $typeRepository,
|
||||
TranslatableStringHelper $translatableStringHelper
|
||||
TranslatableStringHelper $translatableStringHelper,
|
||||
RollingDateConverterInterface $rollingDateConverter
|
||||
) {
|
||||
$this->typeRepository = $typeRepository;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->rollingDateConverter = $rollingDateConverter;
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
@@ -60,7 +64,9 @@ class CompositionAggregator implements AggregatorInterface
|
||||
->addSelect('IDENTITY(composition_type.householdCompositionType) AS composition_aggregator')
|
||||
->addGroupBy('composition_aggregator');
|
||||
|
||||
$qb->setParameter('ondate_composition_type', $data['on_date'], Types::DATE_MUTABLE);
|
||||
$qb->setParameter('ondate_composition_type',
|
||||
$this->rollingDateConverter->convert($data['on_date'])
|
||||
);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@@ -70,8 +76,8 @@ class CompositionAggregator implements AggregatorInterface
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('on_date', ChillDateType::class, [
|
||||
'data' => new DateTime('now'),
|
||||
$builder->add('on_date', PickRollingDateType::class, [
|
||||
'data' => new RollingDate(RollingDate::T_TODAY),
|
||||
]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user