1
0
Fork 0
mirror of synced 2025-04-03 13:23:37 +03:00

#1130 DDC-3300 - optimizing performance (looping over existing classes first): throwing exceptions if the class is not found in the discriminator map

This commit is contained in:
Marco Pivetta 2015-01-15 03:37:50 +01:00
parent 8579baf28c
commit a36bea2951

View file

@ -308,21 +308,37 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
* *
* @param ClassMetadata $metadata * @param ClassMetadata $metadata
* *
* @return void
*
* @throws MappingException * @throws MappingException
*/ */
private function populateDiscriminatorValue(ClassMetadata $metadata) private function populateDiscriminatorValue(ClassMetadata $metadata)
{ {
if (! $metadata->discriminatorValue && $metadata->discriminatorMap) { if ($metadata->discriminatorValue
foreach ($metadata->discriminatorMap as $discriminatorValue => $discriminatorClass) { || ! $metadata->discriminatorMap
if ($metadata->name === $this->getMetadataFor($discriminatorClass)->getName()) { || $metadata->isMappedSuperclass
$metadata->discriminatorValue = $discriminatorValue; || $metadata->reflClass->isAbstract()
) {
break; return;
}
}
//throw MappingException::mappedClassNotPartOfDiscriminatorMap($metadata->name, $metadata->rootEntityName);
} }
foreach ($metadata->discriminatorMap as $discriminatorValue => $discriminatorClass) {
if ($discriminatorClass === $metadata->name) {
$metadata->discriminatorValue = $discriminatorValue;
return;
}
}
foreach ($metadata->discriminatorMap as $discriminatorValue => $discriminatorClass) {
if ($metadata->name === $this->getMetadataFor($discriminatorClass)->getName()) {
$metadata->discriminatorValue = $discriminatorValue;
return;
}
}
throw MappingException::mappedClassNotPartOfDiscriminatorMap($metadata->name, $metadata->rootEntityName);
} }
/** /**