Skip to content

Commit

Permalink
Revert "Fix inherited embeddables and nesting after AnnotationDriver …
Browse files Browse the repository at this point in the history
…change doctrine#8006 (doctrine#8036)"

This reverts commit a9b6b72.
  • Loading branch information
beberlei committed May 12, 2020
1 parent 21a9823 commit 6d11cff
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 173 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
12 changes: 7 additions & 5 deletions lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Expand Up @@ -404,10 +404,10 @@ 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'])) {
if ( ! isset($mapping['declared'])) {
$mapping['declared'] = $parentClass->name;
}
$subClass->addInheritedFieldMapping($mapping);
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
2 changes: 0 additions & 2 deletions lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
Expand Up @@ -278,8 +278,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.

0 comments on commit 6d11cff

Please sign in to comment.