Ajout de nouveaux champs pour gérer les informations supplémentaires sur la personne dans UpsertMessage et mise à jour de PersonUpsertHandler pour traiter ces informations.

This commit is contained in:
Boris Waaub
2026-03-30 21:21:19 +02:00
parent 4e250dd9eb
commit 3d6139ef03
2 changed files with 63 additions and 1 deletions

View File

@@ -16,7 +16,9 @@ use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Gender;
use Chill\MainBundle\Entity\GenderEnum;
use Chill\MainBundle\Repository\CenterRepositoryInterface;
use Chill\MainBundle\Repository\CountryRepository;
use Chill\MainBundle\Repository\GenderRepository;
use Chill\MainBundle\Repository\LanguageRepository;
use Chill\MainBundle\Repository\PostalCodeRepositoryInterface;
use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Household\MembersEditorFactory;
@@ -25,6 +27,7 @@ use Chill\PersonBundle\Repository\Identifier\PersonIdentifierDefinitionRepositor
use Chill\PersonBundle\Repository\Identifier\PersonIdentifierRepository;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Identifier\PersonIdentifier;
use Chill\PersonBundle\Entity\PersonPhone;
use Chill\PersonBundle\Actions\Upsert\UpsertMessage;
use libphonenumber\NumberParseException;
use Psr\Log\LoggerInterface;
@@ -46,6 +49,8 @@ readonly class PersonUpsertHandler
private MembersEditorFactory $membersEditorFactory,
private PostalCodeRepositoryInterface $postalCodeRepository,
private CenterRepositoryInterface $centerRepository,
private CountryRepository $countryRepository,
private LanguageRepository $languageRepository,
private GenderRepository $genderRepository,
private ClockInterface $clock,
private \libphonenumber\PhoneNumberUtil $phoneNumberUtil,
@@ -204,6 +209,63 @@ readonly class PersonUpsertHandler
$person->setCenter($center);
}
// Handle countryOfBirth
if (null !== $message->countryOfBirth) {
$country = $this->countryRepository->findOneBy(['countryCode' => $message->countryOfBirth]);
if (null !== $country) {
$person->setCountryOfBirth($country);
} else {
$this->logger->warning(self::LOG_PREFIX.'Country not found for code: '.$message->countryOfBirth);
}
}
// Handle placeOfBirth
if (null !== $message->placeOfBirth) {
$person->setPlaceOfBirth($message->placeOfBirth);
}
// Handle deathdate
if (null !== $message->deathdate) {
try {
$person->setDeathdate(new \DateTimeImmutable($message->deathdate));
} catch (\Exception $e) {
$this->logger->error(self::LOG_PREFIX.'Could not parse deathdate: '.$message->deathdate, [
'exception' => $e->getTraceAsString(),
'deathdate' => $message->deathdate,
]);
}
}
// Handle spokenLanguages
if (null !== $message->spokenLanguages && [] !== $message->spokenLanguages) {
foreach ($message->spokenLanguages as $languageCode) {
$language = $this->languageRepository->findOneBy(['id' => $languageCode]);
if (null !== $language) {
$person->addSpokenLanguage($language);
} else {
$this->logger->warning(self::LOG_PREFIX.'Language not found for code: '.$languageCode);
}
}
}
// Handle otherPhoneNumbers
if (null !== $message->otherPhoneNumbers && [] !== $message->otherPhoneNumbers) {
foreach ($message->otherPhoneNumbers as $phoneNumber) {
try {
$parsedNumber = $this->phoneNumberUtil->parse($phoneNumber);
$personPhone = new PersonPhone();
$personPhone->setPhonenumber($parsedNumber);
$person->addOtherPhoneNumber($personPhone);
$this->entityManager->persist($personPhone);
} catch (NumberParseException $e) {
$this->logger->warning(self::LOG_PREFIX.'Could not parse otherPhoneNumber', [
'exception' => $e->getTraceAsString(),
'phoneNumber' => $phoneNumber,
]);
}
}
}
// mobileNumber and phoneNumber
if (null !== $message->phoneNumber) {
try {

View File

@@ -14,7 +14,7 @@ namespace Chill\PersonBundle\Actions\Upsert;
class UpsertMessage
{
public string $externalId;
public string $moreExternalIds;
public ?array $moreExternalIds = [];
public int $personIdentifierDefinitionId;
public ?string $firstName = null;
public ?string $lastName = null;