From fea79c79df7fd751a0e276c125d4ea768c84e6e4 Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Sun, 29 Oct 2023 14:37:08 -0400 Subject: [PATCH] Accept both ClassMetadata and ClassMetadataInfo objects from the ORM --- src/Mapping/ExtensionMetadataFactory.php | 7 ++++--- src/Mapping/MappedEventSubscriber.php | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Mapping/ExtensionMetadataFactory.php b/src/Mapping/ExtensionMetadataFactory.php index 011f29164b..aa66605fed 100644 --- a/src/Mapping/ExtensionMetadataFactory.php +++ b/src/Mapping/ExtensionMetadataFactory.php @@ -12,7 +12,8 @@ use Doctrine\Bundle\DoctrineBundle\Mapping\MappingDriver as DoctrineBundleMappingDriver; use Doctrine\Common\Annotations\Reader; use Doctrine\ODM\MongoDB\Mapping\ClassMetadata as DocumentClassMetadata; -use Doctrine\ORM\Mapping\ClassMetadataInfo as EntityClassMetadata; +use Doctrine\ORM\Mapping\ClassMetadata as EntityClassMetadata; +use Doctrine\ORM\Mapping\ClassMetadataInfo as LegacyEntityClassMetadata; use Doctrine\Persistence\Mapping\ClassMetadata; use Doctrine\Persistence\Mapping\Driver\DefaultFileLocator; use Doctrine\Persistence\Mapping\Driver\MappingDriver; @@ -95,7 +96,7 @@ public function __construct(ObjectManager $objectManager, string $extensionNames /** * Reads extension metadata * - * @param ClassMetadata&(DocumentClassMetadata|EntityClassMetadata) $meta + * @param ClassMetadata&(DocumentClassMetadata|EntityClassMetadata|LegacyEntityClassMetadata) $meta * * @return array the metatada configuration */ @@ -116,7 +117,7 @@ public function getExtensionMetadata($meta) $class = $this->objectManager->getClassMetadata($parentClass); - assert($class instanceof DocumentClassMetadata || $class instanceof EntityClassMetadata); + assert($class instanceof DocumentClassMetadata || $class instanceof EntityClassMetadata || $class instanceof LegacyEntityClassMetadata); $extendedMetadata = $this->driver->readExtendedMetadata($class, $config); diff --git a/src/Mapping/MappedEventSubscriber.php b/src/Mapping/MappedEventSubscriber.php index d93815a39b..73800fb27c 100644 --- a/src/Mapping/MappedEventSubscriber.php +++ b/src/Mapping/MappedEventSubscriber.php @@ -17,7 +17,8 @@ use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ODM\MongoDB\Mapping\ClassMetadata as DocumentClassMetadata; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Mapping\ClassMetadataInfo as EntityClassMetadata; +use Doctrine\ORM\Mapping\ClassMetadata as EntityClassMetadata; +use Doctrine\ORM\Mapping\ClassMetadataInfo as LegacyEntityClassMetadata; use Doctrine\Persistence\Mapping\AbstractClassMetadataFactory; use Doctrine\Persistence\Mapping\ClassMetadata; use Doctrine\Persistence\ObjectManager; @@ -229,7 +230,7 @@ final public function setCacheItemPool(CacheItemPoolInterface $cacheItemPool): v */ public function loadMetadataForObjectClass(ObjectManager $objectManager, $metadata) { - assert($metadata instanceof DocumentClassMetadata || $metadata instanceof EntityClassMetadata); + assert($metadata instanceof DocumentClassMetadata || $metadata instanceof EntityClassMetadata || $metadata instanceof LegacyEntityClassMetadata); $factory = $this->getExtensionMetadataFactory($objectManager);