26 private $converterUtils;
34 $this->converter = $converter;
35 $this->converterUtils = $converterUtils;
43 if ($node->nodeType !== XML_ELEMENT_NODE) {
56 private function toArray(\DOMNode $node)
58 if ($node->localName ==
'url') {
59 $urlResult = $this->converter->convert($node, [
'type' =>
'url']);
60 return $urlResult ?: [];
66 if ($this->hasChildElements($node)) {
69 foreach ($node->childNodes as $childNode) {
70 if ($childNode->nodeType === XML_ELEMENT_NODE) {
71 $result[
'item'][$this->converterUtils->getComponentName($childNode)] = $this->
toArray($childNode);
75 if ($node->nodeType == XML_ELEMENT_NODE) {
77 $attributesResult = [];
80 if ($node->hasAttributes()) {
81 $attributesResult = $this->processAttributes($node);
84 $result = array_merge([
'value' => trim($node->nodeValue)], $childResult, $attributesResult);
97 private function hasChildElements(\DOMNode $node)
99 if ($node->hasChildNodes()) {
100 foreach ($node->childNodes as $childNode) {
101 if ($childNode->nodeType == XML_ELEMENT_NODE) {
115 private function processAttributes(\DOMNode $node)
convert(\DOMNode $node, array $data=[])
__construct(ConverterInterface $converter, ConverterUtils $converterUtils)