Handle case where form is null in PersonIdentifiersDataMapper

- Added a null check for forms in `PersonIdentifiersDataMapper` to prevent potential errors: a form is not present at all steps (on creation / on edit)
- Skips processing if the form is not found.
This commit is contained in:
2025-10-07 11:29:45 +02:00
parent 6d8ef035ea
commit 8740025dbd
2 changed files with 7 additions and 2 deletions

View File

@@ -38,7 +38,12 @@ final readonly class PersonIdentifiersDataMapper implements DataMapperInterface
if (!$worker->getDefinition()->isEditableByUsers()) { if (!$worker->getDefinition()->isEditableByUsers()) {
continue; continue;
} }
$form = $formsByKey['identifier_'.$worker->getDefinition()->getId()];
$form = $formsByKey['identifier_'.$worker->getDefinition()->getId()] ?? null;
if (null === $form) {
continue;
}
$identifier = $viewData->findFirst(fn (int $key, PersonIdentifier $identifier) => $worker->getDefinition() === $identifier->getDefinition()); $identifier = $viewData->findFirst(fn (int $key, PersonIdentifier $identifier) => $worker->getDefinition() === $identifier->getDefinition());
if (null === $identifier) { if (null === $identifier) {
$identifier = new PersonIdentifier($worker->getDefinition()); $identifier = new PersonIdentifier($worker->getDefinition());

View File

@@ -34,7 +34,7 @@ interface PersonIdentifierEngineInterface
public function isEmpty(PersonIdentifier $identifier): bool; public function isEmpty(PersonIdentifier $identifier): bool;
/** /**
* Return a list of @link{IdentifierViolationDTO} to generatie violation errors. * Return a list of @see{IdentifierViolationDTO} to generatie violation errors.
* *
* @return list<IdentifierViolationDTO> * @return list<IdentifierViolationDTO>
*/ */