Skip to content

Commit 2aa4cb6

Browse files
cyganmmariowtm
authored andcommitted
Issue #14 add proxy check to hydrateProperties
1 parent 5ea4554 commit 2aa4cb6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/ArrayHydrator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use Doctrine\DBAL\Types\Type;
55
use Doctrine\ORM\EntityManagerInterface;
66
use Doctrine\ORM\Mapping\ClassMetadataInfo;
7+
use Doctrine\Persistence\Proxy;
78
use Exception;
89

910
class ArrayHydrator
@@ -106,7 +107,11 @@ public function setHydrateBy($hydrateBy)
106107
*/
107108
protected function hydrateProperties($entity, $data)
108109
{
109-
$reflectionObject = new \ReflectionObject($entity);
110+
if ($entity instanceof Proxy) {
111+
$reflectionObject = (new \ReflectionObject($entity))->getParentClass();
112+
} else {
113+
$reflectionObject = new \ReflectionObject($entity);
114+
}
110115

111116
$metaData = $this->entityManager->getClassMetadata(get_class($entity));
112117

0 commit comments

Comments
 (0)