Skip to content

Commit

Permalink
fix mapping objects vs arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher committed Feb 24, 2024
1 parent fe87bbf commit ee1aee2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/FieldDescription/FieldDescriptionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Sonata\DoctrineORMAdminBundle\FieldDescription;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\AssociationMapping;
use Doctrine\ORM\Mapping\ClassMetadata;
use Sonata\AdminBundle\FieldDescription\FieldDescriptionFactoryInterface;
use Sonata\AdminBundle\FieldDescription\FieldDescriptionInterface;
Expand All @@ -29,11 +30,19 @@ public function create(string $class, string $name, array $options = []): FieldD
{
[$metadata, $propertyName, $parentAssociationMappings] = $this->getParentMetadataForProperty($class, $name);

$associationMapping = $metadata->associationMappings[$propertyName] ?? [];

if ($associationMapping instanceof AssociationMapping) {

Check failure on line 35 in src/FieldDescription/FieldDescriptionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan

Class Doctrine\ORM\Mapping\AssociationMapping not found.

Check failure on line 35 in src/FieldDescription/FieldDescriptionFactory.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedClass

src/FieldDescription/FieldDescriptionFactory.php:35:44: UndefinedClass: Class, interface or enum named Doctrine\ORM\Mapping\AssociationMapping does not exist (see https://psalm.dev/019)
$associationMappingType = $associationMapping->type();
$associationMapping = (array) $associationMapping;
$associationMapping['type'] = $associationMappingType;
}

return new FieldDescription(
$name,
$options,
$metadata->fieldMappings[$propertyName] ?? [],
$metadata->associationMappings[$propertyName] ?? [],
(array) ($metadata->fieldMappings[$propertyName] ?? []),
$associationMapping,
$parentAssociationMappings,
$propertyName
);
Expand Down

0 comments on commit ee1aee2

Please sign in to comment.