/** * 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); } }