From 4680a7b861f29f2f0dd608a129410ad2227c3f45 Mon Sep 17 00:00:00 2001 From: Guilherme Blanco Date: Fri, 20 Feb 2015 14:10:28 -0500 Subject: [PATCH] Fixed bug where embedded reflection fields were never exposed to userland. --- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 1 + .../ORM/Persisters/Entity/BasicEntityPersister.php | 9 ++++++++- tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 51791af0d..ad418418a 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -941,6 +941,7 @@ class ClassMetadataInfo implements ClassMetadata } $parentReflFields[$property] = $reflService->getAccessibleProperty($this->name, $property); + $this->reflFields[$property] = $reflService->getAccessibleProperty($this->name, $property); } foreach ($this->fieldMappings as $field => $mapping) { diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 5d096a9dc..a86f8bc21 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -613,10 +613,13 @@ class BasicEntityPersister implements EntityPersister continue; } + if (isset($this->class->embeddedClasses[$field])) { + continue; + } + $newVal = $change[1]; if ( ! isset($this->class->associationMappings[$field])) { - $columnName = $this->class->columnNames[$field]; $this->columnTypes[$columnName] = $this->class->fieldMappings[$field]['type']; $result[$this->getOwningTable($field)][$columnName] = $newVal; @@ -1420,6 +1423,10 @@ class BasicEntityPersister implements EntityPersister continue; } + if (isset($this->class->embeddedClasses[$name])) { + continue; + } + if (isset($this->class->associationMappings[$name])) { $assoc = $this->class->associationMappings[$name]; if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) { diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index 28a7e2664..de3ab7ee0 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -24,6 +24,14 @@ class ValueObjectsTest extends \Doctrine\Tests\OrmFunctionalTestCase } } + public function testMetadataHasReflectionEmbeddablesAccessible() + { + $classMetadata = $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Person'); + + $this->assertInstanceOf('Doctrine\Common\Reflection\RuntimePublicReflectionProperty', $classMetadata->getReflectionProperty('address')); + $this->assertInstanceOf('Doctrine\ORM\Mapping\ReflectionEmbeddedProperty', $classMetadata->getReflectionProperty('address.street')); + } + public function testCRUD() { $person = new DDC93Person();