use translatablestringhelper

This commit is contained in:
Julie Lenaerts 2022-08-09 16:13:24 +02:00
parent ed1dde4713
commit 9a2af662c0
4 changed files with 21 additions and 14 deletions

View File

@ -12,21 +12,23 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\PersonAggregators; namespace Chill\PersonBundle\Export\Aggregator\PersonAggregators;
use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Entity\Person; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Repository\MaritalStatusRepository; use Chill\PersonBundle\Repository\MaritalStatusRepository;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
final class MaritalStatusAggregator implements AggregatorInterface final class MaritalStatusAggregator implements AggregatorInterface
{ {
private MaritalStatusRepository $maritalStatusRepository; private MaritalStatusRepository $maritalStatusRepository;
public function __construct(MaritalStatusRepository $maritalStatusRepository) private TranslatableStringHelper $translatableStringHelper;
public function __construct(MaritalStatusRepository $maritalStatusRepository, TranslatableStringHelper $translatableStringHelper)
{ {
$this->maritalStatusRepository = $maritalStatusRepository; $this->maritalStatusRepository = $maritalStatusRepository;
$this->translatableStringHelper = $translatableStringHelper;
} }
public function addRole() public function addRole()
@ -66,7 +68,7 @@ final class MaritalStatusAggregator implements AggregatorInterface
$g = $this->maritalStatusRepository->find($value); $g = $this->maritalStatusRepository->find($value);
return $g->getName()['fr']; return $this->translatableStringHelper->localize($g->getName());
}; };
} }

View File

@ -12,9 +12,9 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators; namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository; use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
@ -22,11 +22,12 @@ final class ActionTypeAggregator implements AggregatorInterface
{ {
private SocialActionRepository $socialActionRepository; private SocialActionRepository $socialActionRepository;
private SocialActionRender $socialActionRender; private TranslatableStringHelper $translatableStringHelper;
public function __construct(SocialActionRepository $socialActionRepository) public function __construct(SocialActionRepository $socialActionRepository, TranslatableStringHelper $translatableStringHelper)
{ {
$this->socialActionRepository = $socialActionRepository; $this->socialActionRepository = $socialActionRepository;
$this->translatableStringHelper = $translatableStringHelper;
} }
public function addRole() public function addRole()
@ -69,7 +70,7 @@ final class ActionTypeAggregator implements AggregatorInterface
$sa = $this->socialActionRepository->find($value); $sa = $this->socialActionRepository->find($value);
return $sa->getTitle()['fr']; return $this->translatableStringHelper->localize($sa->getTitle());
}; };
} }

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators; namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations; use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Repository\SocialWork\GoalRepository; use Chill\PersonBundle\Repository\SocialWork\GoalRepository;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
@ -21,9 +22,12 @@ final class GoalAggregator implements AggregatorInterface
{ {
private GoalRepository $goalRepository; private GoalRepository $goalRepository;
public function __construct(GoalRepository $goalRepository) private TranslatableStringHelper $translatableStringHelper;
public function __construct(GoalRepository $goalRepository, TranslatableStringHelper $translatableStringHelper)
{ {
$this->goalRepository = $goalRepository; $this->goalRepository = $goalRepository;
$this->translatableStringHelper = $translatableStringHelper;
} }
public function addRole() public function addRole()
@ -65,7 +69,7 @@ final class GoalAggregator implements AggregatorInterface
$g = $this->goalRepository->find($value); $g = $this->goalRepository->find($value);
return $g->getTitle()['fr']; return $this->translatableStringHelper->localize($g->getTitle());
}; };
} }

View File

@ -33,8 +33,8 @@ final class ResultAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data) public function alterQuery(QueryBuilder $qb, $data)
{ {
$qb->join('acpw.results', 'r'); $qb->join('acpw.results', 'res');
$qb->addSelect('r.id as result_aggregator'); $qb->addSelect('res.id as result_aggregator');
$groupBy = $qb->getDQLPart('groupBy'); $groupBy = $qb->getDQLPart('groupBy');
@ -65,7 +65,7 @@ final class ResultAggregator implements AggregatorInterface
$g = $this->resultRepository->find($value); $g = $this->resultRepository->find($value);
return $g->getTitle()['fr']; return $this->translatableStringHelper->localize($g->getTitle());
}; };
} }