/**
  * {@inheritdoc}
  */
 public function hydrate($document, MetaInformationInterface $metaInformation)
 {
     $sourceTargetEntity = $metaInformation->getEntity();
     $targetEntity = clone $sourceTargetEntity;
     $metaInformation->setEntity($targetEntity);
     return $this->valueHydrator->hydrate($document, $metaInformation);
 }
 /**
  * {@inheritdoc}
  */
 public function hydrate($document, MetaInformationInterface $metaInformation)
 {
     $targetEntity = $metaInformation->getEntity();
     $reflectionClass = new \ReflectionClass($targetEntity);
     foreach ($document as $property => $value) {
         if ($property === MetaInformationInterface::DOCUMENT_KEY_FIELD_NAME) {
             $value = $this->removePrefixedKeyFieldName($value);
         }
         // skip field if value is array or "flat" object
         // hydrated object should contain a list of real entities / entity
         if ($this->mapValue($property, $value, $metaInformation) == false) {
             continue;
         }
         try {
             $classProperty = $reflectionClass->getProperty($this->removeFieldSuffix($property));
         } catch (\ReflectionException $e) {
             try {
                 $classProperty = $reflectionClass->getProperty($this->toCamelCase($this->removeFieldSuffix($property)));
             } catch (\ReflectionException $e) {
                 continue;
             }
         }
         $classProperty->setAccessible(true);
         $classProperty->setValue($targetEntity, $value);
     }
     return $targetEntity;
 }
Exemple #3
0
 /**
  * {@inheritdoc}
  */
 public function hydrate($document, MetaInformationInterface $metaInformation)
 {
     $targetEntity = $metaInformation->getEntity();
     $reflectionClass = new \ReflectionClass($targetEntity);
     foreach ($document as $property => $value) {
         try {
             $classProperty = $reflectionClass->getProperty($this->removeFieldSuffix($property));
         } catch (\ReflectionException $e) {
             try {
                 $classProperty = $reflectionClass->getProperty($this->toCamelCase($this->removeFieldSuffix($property)));
             } catch (\ReflectionException $e) {
                 continue;
             }
         }
         $classProperty->setAccessible(true);
         $classProperty->setValue($targetEntity, $value);
     }
     return $targetEntity;
 }
 /**
  * @param MetaInformationInterface $metaInformation
  */
 public function setMetaInformation($metaInformation)
 {
     $this->metaInformation = $metaInformation;
     $this->entity = $metaInformation->getEntity();
     $this->index = $metaInformation->getIndex();
 }