1
0
mirror of synced 2025-01-18 22:41:43 +03:00

DDC-1204, DDC-1203 - No need to throw this exception for abstract classes anymore

This commit is contained in:
Benjamin Eberlei 2011-06-30 20:57:29 +02:00
parent 5362206297
commit a0a81db045
3 changed files with 5 additions and 4 deletions

View File

@ -327,7 +327,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
if (!$class->discriminatorColumn) {
throw MappingException::missingDiscriminatorColumn($class->name);
}
} else if ($parent && !in_array($class->name, array_values($class->discriminatorMap))) {
} 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);
}

View File

@ -289,7 +289,8 @@ class MappingException extends \Doctrine\ORM\ORMException
{
return new self(
"Entity '" . $className . "' has to be part of the descriminator map of '" . $rootClassName . "' " .
"to be properly mapped in the inheritance hierachy. If you want to avoid instantiation of this type mark it abstract."
"to be properly mapped in the inheritance hierachy. Alternatively you can make '".$className."' an abstract class " .
"to avoid this exception from occuring."
);
}
}

View File

@ -85,7 +85,7 @@ class BasicInheritanceMappingTest extends \Doctrine\Tests\OrmTestCase
*/
public function testUnmappedEntityInHierachy()
{
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException', "Entity 'Doctrine\Tests\ORM\Mapping\HierachyBEntity' has to be part of the descriminator map of 'Doctrine\Tests\ORM\Mapping\HierachyBase' to be properly mapped in the inheritance hierachy. If you want to avoid instantiation of this type mark it abstract.");
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException', "Entity 'Doctrine\Tests\ORM\Mapping\HierachyBEntity' has to be part of the descriminator map of 'Doctrine\Tests\ORM\Mapping\HierachyBase' to be properly mapped in the inheritance hierachy. Alternatively you can make 'Doctrine\Tests\ORM\Mapping\HierachyBEntity' an abstract class to avoid this exception from occuring.");
$class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\HierachyE');
}
@ -209,7 +209,7 @@ abstract class HierachyASuperclass extends HierachyBase
/**
* @Entity
*/
abstract class HierachyBEntity extends HierachyBase
class HierachyBEntity extends HierachyBase
{
/** @Column(type="string") */
public $b;