Skip to content

Commit

Permalink
bug #6212 Prevent a crash when loading filters (pkly)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.x branch.

Discussion
----------

Prevent a crash when loading filters

Fixes #6211

Commits
-------

f6f806c Prevent a crash when loading filters
  • Loading branch information
javiereguiluz committed Oct 20, 2024
2 parents f907d7a + f6f806c commit f9923f4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Field/Configurator/AssociationConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@ public function configure(FieldDto $field, EntityDto $entityDto, AdminContext $c
$field->setFormTypeOptionIfNotSet('class', $targetEntityFqcn);

try {
$relatedEntityId = $accessor->getValue($entityDto->getInstance(), $propertyName.'.'.$metadata->getIdentifierFieldNames()[0]);
$relatedEntityDto = $this->entityFactory->create($targetEntityFqcn, $relatedEntityId);
if (null !== $entityDto->getInstance()) {
$relatedEntityId = $accessor->getValue($entityDto->getInstance(), $propertyName.'.'.$metadata->getIdentifierFieldNames()[0]);
$relatedEntityDto = $this->entityFactory->create($targetEntityFqcn, $relatedEntityId);

$field->setCustomOption(AssociationField::OPTION_RELATED_URL, $this->generateLinkToAssociatedEntity($targetCrudControllerFqcn, $relatedEntityDto));
$field->setFormattedValue($this->formatAsString($relatedEntityDto->getInstance(), $relatedEntityDto));
$field->setCustomOption(AssociationField::OPTION_RELATED_URL, $this->generateLinkToAssociatedEntity($targetCrudControllerFqcn, $relatedEntityDto));
$field->setFormattedValue($this->formatAsString($relatedEntityDto->getInstance(), $relatedEntityDto));
}
} catch (UnexpectedTypeException) {
// this may crash if something in the tree is null, so just do nothing then
}
Expand Down

0 comments on commit f9923f4

Please sign in to comment.