Skip to content

Commit

Permalink
[GH-8031] Bugfix: Get working again on nested embeddables in inherite…
Browse files Browse the repository at this point in the history
…d embeddables.
  • Loading branch information
beberlei committed Mar 1, 2020
1 parent 39dfce6 commit 961b20b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
4 changes: 0 additions & 4 deletions lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Expand Up @@ -469,10 +469,6 @@ 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
32 changes: 30 additions & 2 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH8031Test.php
Expand Up @@ -19,7 +19,7 @@ protected function setUp()

public function testEntityIsFetched()
{
$entity = new GH8031Invoice(new GH8031InvoiceCode(1, 2020));
$entity = new GH8031Invoice(new GH8031InvoiceCode(1, 2020, new GH8031Nested(10)));
$this->_em->persist($entity);
$this->_em->flush();
$this->_em->clear();
Expand All @@ -38,6 +38,28 @@ public function testEntityIsFetched()
}
}

/**
* @Embeddable
*/
class GH8031Nested
{
/**
* @Column(type="integer", name="number", length=6)
* @var int
*/
protected $number;

public function __construct(int $number)
{
$this->number = $number;
}

public function getNumber() : int
{
return $this->number;
}
}

/**
* @Embeddable
*/
Expand All @@ -62,10 +84,16 @@ abstract class GH8031AbstractYearSequenceValue
*/
protected $year;

public function __construct(int $number, int $year)
/**
* @Embedded(class=GH8031Nested::class)
*/
protected $nested;

public function __construct(int $number, int $year, GH8031Nested $nested)
{
$this->number = $number;
$this->year = $year;
$this->nested = $nested;
}

public function getNumber() : int
Expand Down

0 comments on commit 961b20b

Please sign in to comment.