26 private $converterUtils;
34 $this->converter = $converter;
35 $this->converterUtils = $converterUtils;
43 if (!$node->hasChildNodes()) {
51 if ($node->nodeType !== XML_ELEMENT_NODE) {
55 return $this->toArray($node);
64 private function toArray(\DOMNode $node)
66 if ($node->localName ==
'url') {
67 $urlResult = $this->converter->convert($node, [
'type' =>
'url']);
68 return $urlResult ?: [];
73 if ($this->hasChildElements($node)) {
74 $result = $this->processChildNodes($node);
76 if ($node->nodeType == XML_ELEMENT_NODE) {
78 $attributesResult = [];
81 if ($node->hasAttributes()) {
82 $attributesResult = $this->processAttributes($node);
85 $result = array_merge([
'value' => trim($node->nodeValue)], $childResult, $attributesResult);
98 private function hasChildElements(\DOMNode $node)
100 if ($node->hasChildNodes()) {
101 foreach ($node->childNodes as $childNode) {
102 if ($childNode->nodeType == XML_ELEMENT_NODE) {
116 private function processAttributes(\DOMNode $node)
138 private function processChildNodes(\DOMNode $node)
143 foreach ($node->childNodes as $childNode) {
144 if ($childNode->nodeType === XML_ELEMENT_NODE) {
145 $result[
'item'][$this->converterUtils->getComponentName($childNode)] = $this->toArray($childNode);
148 if ($node->nodeType == XML_ELEMENT_NODE && $node->nodeName ==
'button') {
151 'value' => $node->getAttribute(
'name'),