1
0
mirror of synced 2025-02-20 06:03:15 +03:00

Throw exception on embeddables in embeddables.

This commit is contained in:
Jan Kramer 2013-12-12 20:55:32 +01:00
parent 496fa85641
commit 43e37d4f2f
3 changed files with 45 additions and 0 deletions

View File

@ -3162,6 +3162,10 @@ class ClassMetadataInfo implements ClassMetadata
*/
public function mapEmbedded(array $mapping)
{
if ($this->isEmbeddedClass) {
throw MappingException::noEmbeddablesInEmbeddable($this->name);
}
$this->assertFieldNotMapped($mapping['fieldName']);
$this->embeddedClasses[$mapping['fieldName']] = array(

View File

@ -781,4 +781,12 @@ class MappingException extends \Doctrine\ORM\ORMException
sprintf('Missing "sequenceName" attribute for sequence id generator definition on class "%s".', $className)
);
}
public static function noEmbeddablesInEmbeddable($className)
{
return new self(sprintf(
"You embedded one or more embeddables in embeddable '%s', but this behavior is currently unsupported.",
$className
));
}
}

View File

@ -162,6 +162,23 @@ class ValueObjectsTest extends \Doctrine\Tests\OrmFunctionalTestCase
$reloadedCar = $this->_em->find(__NAMESPACE__.'\\DDC93Car', $car->id);
$this->assertEquals($car, $reloadedCar);
}
public function testEmbeddableWithinEmbeddable()
{
$this->setExpectedException(
'Doctrine\ORM\Mapping\MappingException',
sprintf(
"You embedded one or more embeddables in embeddable '%s', but this behavior is currently unsupported.",
__NAMESPACE__ . '\DDC93ContactInfo'
)
);
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Customer'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93ContactInfo'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93PhoneNumber')
));
}
}
/**
@ -263,3 +280,19 @@ class DDC93Address
}
}
/** @Entity */
class DDC93Customer
{
/** @Id @GeneratedValue @Column(type="integer") */
private $id;
/** @Embedded(class = "DDC93ContactInfo", columnPrefix = "contact_info_") */
private $contactInfo;
}
/** @Embeddable */
class DDC93ContactInfo
{
/** @Embedded(class = "DDC93Address") */
private $address;
}