fix nationality aggregator

This commit is contained in:
Julie Lenaerts 2022-08-10 10:35:32 +02:00
parent 20949fdb5c
commit 6eddb420cc
2 changed files with 11 additions and 2 deletions

View File

@ -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);

View File

@ -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,10 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV
];
}
return static function (string $value) use ($labels): string {
return function ($value) use ($labels): string {
return $labels[$value];
};
}
public function getQueryKeys($data)