Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Converter.php
Go to the documentation of this file.
1 <?php
7 
9 {
16  public function convert($source)
17  {
18  $output = [];
20  $types = $source->getElementsByTagName('type');
22  foreach ($types as $type) {
23  $typeConfig = [];
24  foreach ($type->attributes as $attribute) {
25  $typeConfig[$attribute->nodeName] = $attribute->nodeValue;
26  }
28  foreach ($type->childNodes as $childNode) {
29  if ($childNode->nodeType == XML_ELEMENT_NODE ||
30  ($childNode->nodeType == XML_CDATA_SECTION_NODE ||
31  $childNode->nodeType == XML_TEXT_NODE && trim(
32  $childNode->nodeValue
33  ) != '')
34  ) {
35  $typeConfig[$childNode->nodeName] = $childNode->nodeValue;
36  }
37  }
38  $output[$type->attributes->getNamedItem('name')->nodeValue] = $typeConfig;
39  }
40  return ['types' => $output];
41  }
42 }
$source
Definition: source.php:23
$type
Definition: item.phtml:13