Skip to content

Commit 5c48add

Browse files
committed
Skip embedded fields in embeddables
This change skips the creation of mapped fields inside embeddables. Consider the PHP Money class: ```php public class Invoice { /** * @var Money * * @Orm\Embedded(class="Money\Money") */ private $total; } ``` ```php final class Money implements \JsonSerializable { /** * @var Currency */ private $currency; } ``` Here, Money has the mapped field `Currency`. In doctrine Metadata, this is correctly reflected as `total.currency`. The EntityRegenerator declares a private field `$total.currency` afterwards. The changeset suppresses this behaviour by skipping fields containing a dot as is done a few lines below.
1 parent 08fabae commit 5c48add

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Doctrine/EntityRegenerator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ public function regenerateEntities(string $classOrNamespace)
7676
$embeddedClasses = [];
7777

7878
foreach ($classMetadata->embeddedClasses as $fieldName => $mapping) {
79+
if (false !== strpos($fieldName, '.')) {
80+
continue;
81+
}
82+
7983
$className = $mapping['class'];
8084

8185
$embeddedClasses[$fieldName] = $this->getPathOfClass($className);

0 commit comments

Comments
 (0)