Skip to content

Commit 4d172e2

Browse files
authored
Revert changes to embeddable mapping in 2.7 (#8138)
* Revert "Fix inherited embeddables and nesting after AnnotationDriver change #8006 (#8036)" This reverts commit a9b6b72. * Revert "Make Embeddable not transient" This reverts commit 58677c2. * Housekeeping: CS fixes
1 parent 21a9823 commit 4d172e2

File tree

5 files changed

+7
-178
lines changed

5 files changed

+7
-178
lines changed

docs/en/tutorials/embeddables.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ or address are the primary use case for this feature.
88

99
.. note::
1010

11-
Embeddables can not contain references to entities. They can however compose
12-
other embeddables in addition to holding properties with basic ``@Column``
13-
mapping.
11+
Embeddables can only contain properties with basic ``@Column`` mapping.
1412

1513
For the purposes of this tutorial, we will assume that you have a ``User``
1614
class in your application and you would like to store an address in

lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ private function getShortName($className)
404404
private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass)
405405
{
406406
foreach ($parentClass->fieldMappings as $mapping) {
407-
if (! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass && ! $parentClass->isEmbeddedClass) {
407+
if (! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) {
408408
$mapping['inherited'] = $parentClass->name;
409409
}
410410
if (! isset($mapping['declared'])) {
@@ -472,6 +472,10 @@ private function addInheritedEmbeddedClasses(ClassMetadata $subClass, ClassMetad
472472
private function addNestedEmbeddedClasses(ClassMetadata $subClass, ClassMetadata $parentClass, $prefix)
473473
{
474474
foreach ($subClass->embeddedClasses as $property => $embeddableClass) {
475+
if (isset($embeddableClass['inherited'])) {
476+
continue;
477+
}
478+
475479
$embeddableMetadata = $this->getMetadataFor($embeddableClass['class']);
476480

477481
$parentClass->mapEmbedded(
@@ -779,9 +783,7 @@ protected function getDriver()
779783
*/
780784
protected function isEntity(ClassMetadataInterface $class)
781785
{
782-
assert($class instanceof ClassMetadata);
783-
784-
return $class->isMappedSuperclass === false && $class->isEmbeddedClass === false;
786+
return isset($class->isMappedSuperclass) && $class->isMappedSuperclass === false;
785787
}
786788

787789
/**

lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class AnnotationDriver extends AbstractAnnotationDriver
4545
protected $entityAnnotationClasses = [
4646
Mapping\Entity::class => 1,
4747
Mapping\MappedSuperclass::class => 2,
48-
Mapping\Embeddable::class => 3,
4948
];
5049

5150
/**
@@ -278,8 +277,6 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
278277
/* @var $property \ReflectionProperty */
279278
foreach ($class->getProperties() as $property) {
280279
if ($metadata->isMappedSuperclass && ! $property->isPrivate()
281-
||
282-
$metadata->isEmbeddedClass && $property->getDeclaringClass()->getName() !== $class->getName()
283280
||
284281
$metadata->isInheritedField($property->name)
285282
||

tests/Doctrine/Tests/ORM/Functional/Ticket/GH8031Test.php

Lines changed: 0 additions & 163 deletions
This file was deleted.

tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,6 @@ public function getInfiniteEmbeddableNestingData()
328328
['DDCNestingEmbeddable1', 'DDCNestingEmbeddable4'],
329329
];
330330
}
331-
332-
public function testEmbeddableIsNotTransient()
333-
{
334-
$this->assertFalse($this->_em->getMetadataFactory()->isTransient(DDC93Address::class));
335-
}
336331
}
337332

338333

0 commit comments

Comments
 (0)