Skip to content

Commit

Permalink
EntityExtensionSubscriber::getClassMetadataForEntity now works with m…
Browse files Browse the repository at this point in the history
…ore specific ClassMetadata instead of ClassMetadataInfo

- otherwise, assert in Doctrine/ORM/Mapping/Driver/AnnotationDriver::loadMetadataForClass fails
- see doctrine/orm#9274
  • Loading branch information
vitek-rostislav committed Mar 30, 2022
1 parent d314642 commit 16b6984
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Component/EntityExtension/EntityExtensionSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Doctrine\ORM\Configuration;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use Doctrine\ORM\Events;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\Mapping\ClassMetadata;
use LogicException;
use ReflectionClass;
use Webmozart\Assert\Assert;
Expand Down Expand Up @@ -133,9 +133,9 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void
}

/**
* @param \Doctrine\ORM\Mapping\ClassMetadataInfo $classMetadata
* @param \Doctrine\ORM\Mapping\ClassMetadata $classMetadata
*/
protected function setAssociationMappings(ClassMetadataInfo $classMetadata): void
protected function setAssociationMappings(ClassMetadata $classMetadata): void
{
$currentEntityClass = $classMetadata->getName();

Expand All @@ -157,9 +157,9 @@ protected function setAssociationMappings(ClassMetadataInfo $classMetadata): voi
}

/**
* @param \Doctrine\ORM\Mapping\ClassMetadataInfo $metadata
* @param \Doctrine\ORM\Mapping\ClassMetadata $metadata
*/
protected function setFieldMappings(ClassMetadataInfo $metadata): void
protected function setFieldMappings(ClassMetadata $metadata): void
{
$currentEntityClass = $metadata->getName();

Expand Down Expand Up @@ -213,11 +213,11 @@ protected function isOneOfRegisteredEntities(string $entityClass): bool

/**
* @param class-string $entityClass
* @return \Doctrine\ORM\Mapping\ClassMetadataInfo
* @return \Doctrine\ORM\Mapping\ClassMetadata
*/
protected function getClassMetadataForEntity(string $entityClass): ClassMetadataInfo
protected function getClassMetadataForEntity(string $entityClass): ClassMetadata
{
$classMetadata = new ClassMetadataInfo(
$classMetadata = new ClassMetadata(
$entityClass,
$this->configuration->getNamingStrategy()
);
Expand All @@ -234,9 +234,9 @@ protected function getClassMetadataForEntity(string $entityClass): ClassMetadata
}

/**
* @param \Doctrine\ORM\Mapping\ClassMetadataInfo $classMetadata
* @param \Doctrine\ORM\Mapping\ClassMetadata $classMetadata
*/
protected function updateAssociationMappingsToMappedSuperclasses(ClassMetadataInfo $classMetadata): void
protected function updateAssociationMappingsToMappedSuperclasses(ClassMetadata $classMetadata): void
{
foreach ($classMetadata->getAssociationMappings() as $name => $mapping) {
if (!isset($mapping['targetEntity']) || !$this->isParentEntity($mapping['targetEntity'])) {
Expand Down

0 comments on commit 16b6984

Please sign in to comment.