Skip to content

Commit

Permalink
DDC-1204, DDC-1203 - No need to throw this exception for abstract cla…
Browse files Browse the repository at this point in the history
…sses anymore
  • Loading branch information
beberlei committed Jun 30, 2011
1 parent 5362206 commit a0a81db
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ protected function loadMetadata($name)
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);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ORM/Mapping/MappingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ public static function mappedClassNotPartOfDiscriminatorMap($className, $rootCla
{
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."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function testUnmappedSuperclassInHierachy()
*/
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');
}
Expand Down Expand Up @@ -209,7 +209,7 @@ abstract class HierachyASuperclass extends HierachyBase
/**
* @Entity
*/
abstract class HierachyBEntity extends HierachyBase
class HierachyBEntity extends HierachyBase
{
/** @Column(type="string") */
public $b;
Expand Down

0 comments on commit a0a81db

Please sign in to comment.