Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Dom.php
Go to the documentation of this file.
1 <?php
7 
9 {
10  const ATTRIBUTES = '__attributes__';
11 
12  const CONTENT = '__content__';
13 
20  public function convert($source)
21  {
22  $nodeListData = [];
23 
25  foreach ($source->childNodes as $node) {
26  if ($node->nodeType == XML_ELEMENT_NODE) {
27  $nodeData = [];
29  foreach ($node->attributes as $attribute) {
30  if ($attribute->nodeType == XML_ATTRIBUTE_NODE) {
31  $nodeData[self::ATTRIBUTES][$attribute->nodeName] = $attribute->nodeValue;
32  }
33  }
34  $childrenData = $this->convert($node);
35 
36  if (is_array($childrenData)) {
37  $nodeData = array_merge($nodeData, $childrenData);
38  } else {
39  $nodeData[self::CONTENT] = $childrenData;
40  }
41  $nodeListData[$node->nodeName][] = $nodeData;
42  } elseif ($node->nodeType == XML_CDATA_SECTION_NODE || $node->nodeType == XML_TEXT_NODE && trim(
43  $node->nodeValue
44  ) != ''
45  ) {
46  return $node->nodeValue;
47  }
48  }
49  return $nodeListData;
50  }
51 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$source
Definition: source.php:23