Throw exception on embeddables in embeddables.
This commit is contained in:
parent
496fa85641
commit
43e37d4f2f
@ -3162,6 +3162,10 @@ class ClassMetadataInfo implements ClassMetadata
|
|||||||
*/
|
*/
|
||||||
public function mapEmbedded(array $mapping)
|
public function mapEmbedded(array $mapping)
|
||||||
{
|
{
|
||||||
|
if ($this->isEmbeddedClass) {
|
||||||
|
throw MappingException::noEmbeddablesInEmbeddable($this->name);
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertFieldNotMapped($mapping['fieldName']);
|
$this->assertFieldNotMapped($mapping['fieldName']);
|
||||||
|
|
||||||
$this->embeddedClasses[$mapping['fieldName']] = array(
|
$this->embeddedClasses[$mapping['fieldName']] = array(
|
||||||
|
@ -781,4 +781,12 @@ class MappingException extends \Doctrine\ORM\ORMException
|
|||||||
sprintf('Missing "sequenceName" attribute for sequence id generator definition on class "%s".', $className)
|
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
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,6 +162,23 @@ class ValueObjectsTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
$reloadedCar = $this->_em->find(__NAMESPACE__.'\\DDC93Car', $car->id);
|
$reloadedCar = $this->_em->find(__NAMESPACE__.'\\DDC93Car', $car->id);
|
||||||
$this->assertEquals($car, $reloadedCar);
|
$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;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user