Skip to content

Commit

Permalink
Revert changes to embeddable mapping in 2.7 (#8138)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
beberlei committed May 12, 2020
1 parent 21a9823 commit 4d172e2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 178 deletions.
4 changes: 1 addition & 3 deletions docs/en/tutorials/embeddables.rst
Expand Up @@ -8,9 +8,7 @@ or address are the primary use case for this feature.

.. note::

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

For the purposes of this tutorial, we will assume that you have a ``User``
class in your application and you would like to store an address in
Expand Down
10 changes: 6 additions & 4 deletions lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Expand Up @@ -404,7 +404,7 @@ private function getShortName($className)
private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass)
{
foreach ($parentClass->fieldMappings as $mapping) {
if (! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass && ! $parentClass->isEmbeddedClass) {
if (! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) {
$mapping['inherited'] = $parentClass->name;
}
if (! isset($mapping['declared'])) {
Expand Down Expand Up @@ -472,6 +472,10 @@ private function addInheritedEmbeddedClasses(ClassMetadata $subClass, ClassMetad
private function addNestedEmbeddedClasses(ClassMetadata $subClass, ClassMetadata $parentClass, $prefix)
{
foreach ($subClass->embeddedClasses as $property => $embeddableClass) {
if (isset($embeddableClass['inherited'])) {
continue;
}

$embeddableMetadata = $this->getMetadataFor($embeddableClass['class']);

$parentClass->mapEmbedded(
Expand Down Expand Up @@ -779,9 +783,7 @@ protected function getDriver()
*/
protected function isEntity(ClassMetadataInterface $class)
{
assert($class instanceof ClassMetadata);

return $class->isMappedSuperclass === false && $class->isEmbeddedClass === false;
return isset($class->isMappedSuperclass) && $class->isMappedSuperclass === false;
}

/**
Expand Down
3 changes: 0 additions & 3 deletions lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
Expand Up @@ -45,7 +45,6 @@ class AnnotationDriver extends AbstractAnnotationDriver
protected $entityAnnotationClasses = [
Mapping\Entity::class => 1,
Mapping\MappedSuperclass::class => 2,
Mapping\Embeddable::class => 3,
];

/**
Expand Down Expand Up @@ -278,8 +277,6 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
/* @var $property \ReflectionProperty */
foreach ($class->getProperties() as $property) {
if ($metadata->isMappedSuperclass && ! $property->isPrivate()
||
$metadata->isEmbeddedClass && $property->getDeclaringClass()->getName() !== $class->getName()
||
$metadata->isInheritedField($property->name)
||
Expand Down
163 changes: 0 additions & 163 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH8031Test.php

This file was deleted.

5 changes: 0 additions & 5 deletions tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php
Expand Up @@ -328,11 +328,6 @@ public function getInfiniteEmbeddableNestingData()
['DDCNestingEmbeddable1', 'DDCNestingEmbeddable4'],
];
}

public function testEmbeddableIsNotTransient()
{
$this->assertFalse($this->_em->getMetadataFactory()->isTransient(DDC93Address::class));
}
}


Expand Down

0 comments on commit 4d172e2

Please sign in to comment.