/** * Recursively maps data to children * * @param mixed $data * @param ElementCollection $children */ protected function mapRequestDataToElementCollection($data, ElementCollection $children) { $children->forAll(function (ElementInterface $element) use($data) { $propertyPath = $this->getPropertyPathAsIndex($element); if (array_key_exists($element->getName(), $data)) { $values = $this->propertyAccessor->getValue($data, $propertyPath); $this->mapRequestDataToElement($values, $element); } }); }
/** * {@inheritdoc} */ public function addFilter(FilterInterface $filter) { $this->children->forAll(function (ElementInterface $element) use($filter) { $element->addFilter($filter); }); }
/** * Renders all children elements * * @param ElementCollection $children * * @return array */ protected function renderChildren(ElementCollection $children) { $attributes = []; $children->forAll(function (ElementInterface $child) use(&$attributes) { $attributes[] = $this->renderElement($child); }); return $attributes; }
/** * Maps data using recursion to all children * * @param ElementCollection $children */ protected function mapModelDataToElementCollection(ElementCollection $children) { foreach ($children->all() as $child) { $this->mapModelDataToElement($child); } }
/** * Maps errors to elements children * * @param array $messages * @param ElementCollection $children */ protected function mapMessagesToElementCollection(array $messages, ElementCollection $children) { $children->forAll(function (ElementInterface $element) use($messages) { $this->mapMessagesToElement($messages, $element); }); }