From 112fdf46d08441fc3fb597d9da371a538692e4bb Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 5 Dec 2014 13:00:54 +0100 Subject: [PATCH] Using instantiator to work with internal PHP classes as embeddables --- .../ORM/Mapping/ReflectionEmbeddedProperty.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php b/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php index adde0fa23..659b6cfb7 100644 --- a/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php +++ b/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php @@ -18,6 +18,8 @@ */ namespace Doctrine\ORM\Mapping; + +use Doctrine\Instantiator\Instantiator; use ReflectionProperty; /** @@ -46,6 +48,11 @@ class ReflectionEmbeddedProperty */ private $class; + /** + * @var Instantiator|null + */ + private $instantiator; + /** * @param ReflectionProperty $parentProperty * @param ReflectionProperty $childProperty @@ -83,7 +90,10 @@ class ReflectionEmbeddedProperty $embeddedObject = $this->parentProperty->getValue($object); if (null === $embeddedObject) { - $embeddedObject = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->class), $this->class)); + $this->instantiator = $this->instantiator ?: new Instantiator(); + + $embeddedObject = $this->instantiator->instantiate($this->class); + $this->parentProperty->setValue($object, $embeddedObject); }