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
9 
11 {
18  public function convert($source)
19  {
20  $output = [];
21 
23  $entities = $source->getElementsByTagName('entity');
24 
26  foreach ($entities as $entity) {
27  $entityConfig = [];
28  $attributes = [];
29 
31  foreach ($entity->getElementsByTagName('attribute') as $entityAttribute) {
32  $attributeFields = [];
33  foreach ($entityAttribute->getElementsByTagName('field') as $fieldData) {
34  $locked = $fieldData->attributes->getNamedItem('locked')->nodeValue == "true" ? true : false;
35  $attributeFields[$fieldData->attributes->getNamedItem(
36  'code'
37  )->nodeValue] = [
38  'code' => $fieldData->attributes->getNamedItem('code')->nodeValue,
39  'locked' => $locked,
40  ];
41  }
42  $attributes[$entityAttribute->attributes->getNamedItem('code')->nodeValue] = $attributeFields;
43  }
44  $entityConfig['attributes'] = $attributes;
45  $output[$entity->attributes->getNamedItem('type')->nodeValue] = $entityConfig;
46  }
47 
48  return $output;
49  }
50 }
$source
Definition: source.php:23
$entity
Definition: element.phtml:22
$attributes
Definition: matrix.phtml:13