Fix person list exports

This commit is contained in:
Julie Lenaerts 2024-10-29 18:04:14 +01:00
parent a648fd09b0
commit c79f030310
2 changed files with 16 additions and 2 deletions

View File

@ -16,6 +16,7 @@ use Chill\MainBundle\Export\Helper\ExportAddressHelper;
use Chill\MainBundle\Repository\CenterRepositoryInterface;
use Chill\MainBundle\Repository\CivilityRepositoryInterface;
use Chill\MainBundle\Repository\CountryRepository;
use Chill\MainBundle\Repository\GenderRepository;
use Chill\MainBundle\Repository\LanguageRepositoryInterface;
use Chill\MainBundle\Repository\UserRepositoryInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper;
@ -80,6 +81,7 @@ final readonly class ListPersonHelper
private TranslatableStringHelper $translatableStringHelper,
private TranslatorInterface $translator,
private UserRepositoryInterface $userRepository,
private GenderRepository $genderRepository,
/**
* @var iterable<CustomizeListPersonHelperInterface>
*/
@ -173,6 +175,11 @@ final readonly class ListPersonHelper
break;
case 'gender':
$qb->addSelect('IDENTITY(person.gender) AS gender');
break;
case 'maritalStatus':
$qb->addSelect('IDENTITY(person.maritalStatus) AS maritalStatus');
@ -325,7 +332,13 @@ final readonly class ListPersonHelper
return $this->translator->trans($key);
}
return $this->translator->trans($value);
if (null === $value) {
return '';
}
$gender = $this->genderRepository->find($value);
return $this->translatableStringHelper->localize($gender->getLabel());
};
case 'maritalStatus':

View File

@ -226,7 +226,8 @@ final class PersonControllerCreateTest extends WebTestCase
) {
$creationForm->get(self::FIRSTNAME_INPUT)->setValue($firstname.'_'.uniqid());
$creationForm->get(self::LASTNAME_INPUT)->setValue($lastname.'_'.uniqid());
$creationForm->get(self::GENDER_INPUT)->select('man');
// Todo change hardcoded id
$creationForm->get(self::GENDER_INPUT)->select(5);
$date = $birthdate ?? new \DateTime('1947-02-01');
$creationForm->get(self::BIRTHDATE_INPUT)->setValue($date->format('Y-m-d'));