Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert changes to embeddable mapping in 2.7 #8138

Merged
merged 3 commits into from May 12, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's sad we have so many CS violations on v2.x 😢

$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
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