diff --git a/.changes/unreleased/Fixed-20231120-174603.yaml b/.changes/unreleased/Fixed-20231120-174603.yaml new file mode 100644 index 000000000..0d8b80652 --- /dev/null +++ b/.changes/unreleased/Fixed-20231120-174603.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: 'Export: fix loading of "Group activity by type"' +time: 2023-11-20T17:46:03.999758401+01:00 +custom: + Issue: "211" diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index fa658635b..2c7891dd6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -56,20 +56,15 @@ class ActivityTypeAggregator implements AggregatorInterface public function getLabels($key, array $values, $data): \Closure { - // for performance reason, we load data from db only once - $this->activityTypeRepository->findBy(['id' => $values]); - - return function ($value): string { + return function (null|int|string $value): string { if ('_header' === $value) { return 'Activity type'; } - if (null === $value || '' === $value) { + if (null === $value || '' === $value || null === $t = $this->activityTypeRepository->find($value)) { return ''; } - $t = $this->activityTypeRepository->find($value); - return $this->translatableStringHelper->localize($t->getName()); }; }