コード例 #1
0
 /**
  * {@inheritDoc}
  */
 public function map(PropertyMetadata $property, $object, $value)
 {
     if (!is_object($object)) {
         throw UnexpectedTypeException::create($object, 'object');
     }
     if (!$property->reflection) {
         $objectReflection = Reflection::loadObjectReflection($object);
         $propertyName = $property->getPropertyName();
         $propertyReflection = $objectReflection->getProperty($propertyName);
         if (!$propertyReflection->isPublic()) {
             $propertyReflection->setAccessible(true);
         }
         $property->reflection = $propertyReflection;
     }
     $property->reflection->setValue($object, $value);
 }
コード例 #2
0
 /**
  * Process for mapping new object
  *
  * @param PropertyMetadata $propertyMetadata
  * @param mixed            $parameters
  * @param string           $group
  * @param array            $paths
  *
  * @return object
  */
 protected function doMapNewObject(PropertyMetadata $propertyMetadata, $parameters, $group, array $paths)
 {
     if (is_object($parameters) && $parameters instanceof \Iterator) {
         $parameters = iterator_to_array($parameters);
     }
     if (!is_array($parameters)) {
         $this->controlInvalidType($paths, $parameters);
     }
     $class = $propertyMetadata->getClass();
     $childObject = $this->createObjectFromClass($class);
     $value = $this->doMap($childObject, $parameters, $group, $paths);
     return $value;
 }