From 3c451209c7cdf1fda5f2a04683d52c2a524576a8 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 10 Aug 2022 10:35:32 +0200 Subject: [PATCH] fix nationality aggregator --- .../Repository/CountryRepository.php | 6 ++++++ .../PersonAggregators/NationalityAggregator.php | 13 +++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Repository/CountryRepository.php b/src/Bundle/ChillMainBundle/Repository/CountryRepository.php index 81bea648d..055f41195 100644 --- a/src/Bundle/ChillMainBundle/Repository/CountryRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/CountryRepository.php @@ -14,6 +14,7 @@ namespace Chill\MainBundle\Repository; use Chill\MainBundle\Entity\Country; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ObjectRepository; final class CountryRepository implements ObjectRepository @@ -25,6 +26,11 @@ final class CountryRepository implements ObjectRepository $this->repository = $entityManager->getRepository(Country::class); } + public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder + { + return $this->repository->createQueryBuilder($alias, $indexBy); + } + public function find($id, $lockMode = null, $lockVersion = null): ?Country { return $this->repository->find($id, $lockMode, $lockVersion); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php index b8c9ba166..b4c2bc31a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php @@ -124,17 +124,19 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV ->getQuery() ->getResult(\Doctrine\ORM\Query::HYDRATE_SCALAR); + // initialize array and add blank key for null values $labels = [ '' => $this->translator->trans('without data'), '_header' => $this->translator->trans('Nationality'), ]; + foreach ($countries as $row) { $labels[$row['c_countryCode']] = $this->translatableStringHelper->localize($row['c_name']); } } - + if ('continent' === $data['group_by_level']) { $labels = [ 'EU' => $this->translator->trans('Europe'), @@ -149,9 +151,16 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV ]; } - return static function (string $value) use ($labels): string { + return function ($value) use ($labels): string { + // if ('_header' === $value) { + // return 'Marital status'; + // } return $labels[$value]; }; + // return static function (string $value) use ($labels): string { + // dump($labels[$value]); + // return $labels[$value]; + // }; } public function getQueryKeys($data)