/**
  * Maps data to single element
  *
  * @param mixed            $data
  * @param ElementInterface $child
  */
 protected function mapRequestDataToElement($data, ElementInterface $child)
 {
     $child->setValue($data);
     $children = $child->getChildren();
     if ($children->count()) {
         $this->mapRequestDataToElementCollection($data, $children);
     }
 }
Esempio n. 2
0
 /**
  * Sets value for element
  *
  * @param ElementInterface $element
  */
 protected function setDefaultElementValue(ElementInterface $element)
 {
     $propertyPath = $element->getPropertyPath();
     if ($propertyPath instanceof PropertyPathInterface) {
         if ($this->propertyAccessor->isReadable($this->data, $propertyPath)) {
             $value = $this->propertyAccessor->getValue($this->data, $propertyPath);
             if (0 !== $value && empty($value)) {
                 $value = $element->getDefaultValue();
             }
             if ($element->hasTransformer() && is_object($value)) {
                 $transformer = $element->getTransformer();
                 $value = $transformer->transform($value);
             }
             $element->setValue($value);
         }
     }
 }