Add condition to check if value passed to translatableStringHelper is not null

This commit is contained in:
Julie Lenaerts 2024-10-21 16:18:12 +02:00
parent ddfaa2861e
commit 8b1d73356f

View File

@ -59,7 +59,11 @@ final readonly class GenderAggregator implements AggregatorInterface
return $this->translator->trans('Gender');
}
return (string) $this->translatableStringHelper->localize($this->repository->find((int) $value)?->getLabel());
if (null === $gender = $this-repository->find((int) $value)) {
return '';
}
return (string) $this->translatableStringHelper->localize($gender->getLabel());
};
}