Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Xml.php
Go to the documentation of this file.
1 <?php
7 
12 {
20  public function convert($source)
21  {
22  $output = [];
23 
24  if (!$source instanceof \DOMDocument) {
25  return $output;
26  }
27 
28  $groups = $source->getElementsByTagName('group');
29  foreach ($groups as $group) {
31  if (!$group->hasAttribute('id')) {
32  throw new \InvalidArgumentException('Attribute "id" does not exist');
33  }
34  foreach ($group->childNodes as $child) {
35  if (!$child instanceof \DOMElement) {
36  continue;
37  }
39  $output[$group->getAttribute('id')][$child->nodeName]['value'] = $child->nodeValue;
40  if ($child->hasAttribute('tooltip')) {
41  $output[$group->getAttribute('id')][$child->nodeName]['tooltip'] = $child->getAttribute('tooltip');
42  }
43  }
44  }
45  return $output;
46  }
47 }
$source
Definition: source.php:23
$group
Definition: sections.phtml:16