Skip to content

Commit a0a81db

Browse files
committed
DDC-1204, DDC-1203 - No need to throw this exception for abstract classes anymore
1 parent 5362206 commit a0a81db

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ protected function loadMetadata($name)
327327
if (!$class->discriminatorColumn) {
328328
throw MappingException::missingDiscriminatorColumn($class->name);
329329
}
330-
} else if ($parent && !in_array($class->name, array_values($class->discriminatorMap))) {
330+
} else if ($parent && !$class->reflClass->isAbstract() && !in_array($class->name, array_values($class->discriminatorMap))) {
331331
// enforce discriminator map for all entities of an inheritance hierachy, otherwise problems will occur.
332332
throw MappingException::mappedClassNotPartOfDiscriminatorMap($class->name, $class->rootEntityName);
333333
}

lib/Doctrine/ORM/Mapping/MappingException.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ public static function mappedClassNotPartOfDiscriminatorMap($className, $rootCla
289289
{
290290
return new self(
291291
"Entity '" . $className . "' has to be part of the descriminator map of '" . $rootClassName . "' " .
292-
"to be properly mapped in the inheritance hierachy. If you want to avoid instantiation of this type mark it abstract."
292+
"to be properly mapped in the inheritance hierachy. Alternatively you can make '".$className."' an abstract class " .
293+
"to avoid this exception from occuring."
293294
);
294295
}
295296
}

tests/Doctrine/Tests/ORM/Mapping/BasicInheritanceMappingTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function testUnmappedSuperclassInHierachy()
8585
*/
8686
public function testUnmappedEntityInHierachy()
8787
{
88-
$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.");
88+
$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.");
8989

9090
$class = $this->_factory->getMetadataFor(__NAMESPACE__ . '\\HierachyE');
9191
}
@@ -209,7 +209,7 @@ abstract class HierachyASuperclass extends HierachyBase
209209
/**
210210
* @Entity
211211
*/
212-
abstract class HierachyBEntity extends HierachyBase
212+
class HierachyBEntity extends HierachyBase
213213
{
214214
/** @Column(type="string") */
215215
public $b;

0 commit comments

Comments
 (0)