. */ namespace Doctrine\ORM\Mapping; /** * Acts as a proxy to a nested Property structure, making it look like * just a single scalar property. * * This way value objects "just work" without UnitOfWork, Persisters or Hydrators * needing any changes. */ class ReflectionProxy { private $parentProperty; private $childProperty; private $class; public function __construct($parentProperty, $childProperty, $class) { $this->parentProperty = $parentProperty; $this->childProperty = $childProperty; $this->class = $class; } public function getValue($object) { $embeddedObject = $this->parentProperty->getValue($object); if ($embeddedObject === null) { return null; } return $this->childProperty->getValue($embeddedObject); } public function setValue($object, $value) { $embeddedObject = $this->parentProperty->getValue($object); if ($embeddedObject === null) { $embeddedObject = new $this->class; // TODO $this->parentProperty->setValue($object, $embeddedObject); } $this->childProperty->setValue($embeddedObject, $value); } }