/** * Transforms value if needed or directly changes model property * * @param ElementInterface $child */ protected function setModelValueFromElement(ElementInterface $child) { $propertyPath = $child->getPropertyPath(); if ($propertyPath instanceof PropertyPathInterface) { if ($this->propertyAccessor->isWritable($this->data, $propertyPath)) { if ($child->hasTransformer()) { $transformer = $child->getTransformer(); $transformer->reverseTransform($this->data, $propertyPath, $child->getValue()); } else { $this->propertyAccessor->setValue($this->data, $propertyPath, $child->getValue()); } } } }
/** * Sets errors on element * * @param array $messages * @param ElementInterface $element */ protected function mapMessagesToElement(array $messages, ElementInterface $element) { if ($element->hasPropertyPath()) { $propertyPathParts = explode('.', $element->getPropertyPath(false)); $propertyPath = $this->buildPath($propertyPathParts); if ($this->propertyAccessor->isReadable($messages, $propertyPath)) { $errors = $this->propertyAccessor->getValue($messages, $propertyPath); $element->setError($errors); } } $children = $element->getChildren(); if ($children->count()) { $this->mapMessagesToElementCollection($messages, $children); } }