/** * @param array $elements * @param string $path * @return array */ protected function processElements(array $elements, $path = '') { $result = []; $elements = $this->sortElements($elements); foreach ($elements as $elementName => $elementsConfig) { $elementPath = "{$path}/{$elementName}"; $attributes = ['path' => $elementPath]; if (is_array($elementsConfig)) { $children = []; if (!empty($elementsConfig)) { $attributes += $this->extractElementAttributes($elementsConfig); } if (!empty($elementsConfig)) { $children += $this->processElements($elementsConfig, $elementPath); } $this->dataTransportChildren->setAttributes($children); } $this->dataTransportProtected->setAttributes($attributes); $typeModel = $this->factory->resolve($this->dataTransportProtected['type']); $result[$elementName] = $typeModel->processOutput($this->dataTransportPublic, $this->dataTransportProtected, $this->dataTransportChildren); $this->dataTransportPublic->clearAttributes(); $this->dataTransportProtected->clearAttributes(); $this->dataTransportChildren->clearAttributes(); } return $result; }