/** * 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()); } } } }
/** * Returns child values * * @param ElementInterface $child * @param string $locale * * @return mixed|null */ protected function getChildValue(ElementInterface $child, $locale) { $accessor = $this->getPropertyAccessor(); $value = $child->getValue(); if (is_array($value)) { return $accessor->getValue($value, "[{$locale}]"); } return null; }