DDC-1254 - Dont throw exception about missing id in disconnected metadata factory
This commit is contained in:
parent
4796452b07
commit
c87dedbec5
@ -313,28 +313,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
|||||||
$this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
|
$this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify & complete identifier mapping
|
$this->validateRuntimeMetadata($class, $parent);
|
||||||
if ( ! $class->identifier && ! $class->isMappedSuperclass) {
|
|
||||||
throw MappingException::identifierRequired($className);
|
|
||||||
}
|
|
||||||
|
|
||||||
// verify inheritance
|
|
||||||
if (!$class->isMappedSuperclass && !$class->isInheritanceTypeNone()) {
|
|
||||||
if (!$parent) {
|
|
||||||
if (count($class->discriminatorMap) == 0) {
|
|
||||||
throw MappingException::missingDiscriminatorMap($class->name);
|
|
||||||
}
|
|
||||||
if (!$class->discriminatorColumn) {
|
|
||||||
throw MappingException::missingDiscriminatorColumn($class->name);
|
|
||||||
}
|
|
||||||
} else if ($parent && !$class->reflClass->isAbstract() && !in_array($class->name, array_values($class->discriminatorMap))) {
|
|
||||||
// enforce discriminator map for all entities of an inheritance hierachy, otherwise problems will occur.
|
|
||||||
throw MappingException::mappedClassNotPartOfDiscriminatorMap($class->name, $class->rootEntityName);
|
|
||||||
}
|
|
||||||
} else if ($class->isMappedSuperclass && $class->name == $class->rootEntityName && (count($class->discriminatorMap) || $class->discriminatorColumn)) {
|
|
||||||
// second condition is necessary for mapped superclasses in the middle of an inheritance hierachy
|
|
||||||
throw MappingException::noInheritanceOnMappedSuperClass($class->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->loadedMetadata[$className] = $class;
|
$this->loadedMetadata[$className] = $class;
|
||||||
|
|
||||||
@ -351,6 +330,38 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
|||||||
return $loaded;
|
return $loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate runtime metadata is correctly defined.
|
||||||
|
*
|
||||||
|
* @param ClassMetadata $class
|
||||||
|
* @param ClassMetadata $parent
|
||||||
|
*/
|
||||||
|
protected function validateRuntimeMetadata($class, $parent)
|
||||||
|
{
|
||||||
|
// Verify & complete identifier mapping
|
||||||
|
if ( ! $class->identifier && ! $class->isMappedSuperclass) {
|
||||||
|
throw MappingException::identifierRequired($className);
|
||||||
|
}
|
||||||
|
|
||||||
|
// verify inheritance
|
||||||
|
if (!$class->isMappedSuperclass && !$class->isInheritanceTypeNone()) {
|
||||||
|
if (!$parent) {
|
||||||
|
if (count($class->discriminatorMap) == 0) {
|
||||||
|
throw MappingException::missingDiscriminatorMap($class->name);
|
||||||
|
}
|
||||||
|
if (!$class->discriminatorColumn) {
|
||||||
|
throw MappingException::missingDiscriminatorColumn($class->name);
|
||||||
|
}
|
||||||
|
} else if ($parent && !$class->reflClass->isAbstract() && !in_array($class->name, array_values($class->discriminatorMap))) {
|
||||||
|
// enforce discriminator map for all entities of an inheritance hierachy, otherwise problems will occur.
|
||||||
|
throw MappingException::mappedClassNotPartOfDiscriminatorMap($class->name, $class->rootEntityName);
|
||||||
|
}
|
||||||
|
} else if ($class->isMappedSuperclass && $class->name == $class->rootEntityName && (count($class->discriminatorMap) || $class->discriminatorColumn)) {
|
||||||
|
// second condition is necessary for mapped superclasses in the middle of an inheritance hierachy
|
||||||
|
throw MappingException::noInheritanceOnMappedSuperClass($class->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ClassMetadata instance for the given class name.
|
* Creates a new ClassMetadata instance for the given class name.
|
||||||
*
|
*
|
||||||
|
@ -52,6 +52,17 @@ class DisconnectedClassMetadataFactory extends ClassMetadataFactory
|
|||||||
return $metadata;
|
return $metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate runtime metadata is correctly defined.
|
||||||
|
*
|
||||||
|
* @param ClassMetadata $class
|
||||||
|
* @param ClassMetadata $parent
|
||||||
|
*/
|
||||||
|
protected function validateRuntimeMetadata($class, $parent)
|
||||||
|
{
|
||||||
|
// validate nothing
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user