Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Config.php
Go to the documentation of this file.
1 <?php
8 
13 {
17  protected $urnResolver;
18 
27  public function __construct(
28  $configFiles,
29  \Magento\Framework\Config\DomFactory $domFactory,
30  \Magento\Framework\Config\Dom\UrnResolver $urnResolver
31  ) {
32  $this->urnResolver = $urnResolver;
33  parent::__construct($configFiles, $domFactory);
34  }
35 
41  public function getSchemaFile()
42  {
43  return $this->urnResolver->getRealPath('urn:magento:framework:View/PageLayout/etc/layouts.xsd');
44  }
45 
51  public function getPageLayouts()
52  {
53  return $this->_data;
54  }
55 
62  public function hasPageLayout($pageLayout)
63  {
64  return isset($this->_data[$pageLayout]);
65  }
66 
72  public function getOptions()
73  {
74  return $this->getPageLayouts();
75  }
76 
81  public function toOptionArray($withEmpty = false)
82  {
83  $options = [];
84  foreach ($this->getPageLayouts() as $value => $label) {
85  $options[] = ['label' => $label, 'value' => $value];
86  }
87 
88  if ($withEmpty) {
89  array_unshift($options, [
90  'value' => '',
91  'label' => (string)new \Magento\Framework\Phrase('-- Please Select --')
92  ]);
93  }
94  return $options;
95  }
96 
103  protected function _extractData(\DOMDocument $dom)
104  {
105  $result = [];
106 
108  foreach ($dom->getElementsByTagName('layout') as $layout) {
109  $result[$layout->getAttribute('id')] = trim($layout->nodeValue);
110  }
111  return $result;
112  }
113 
119  protected function _getInitialXml()
120  {
121  return '<?xml version="1.0" encoding="UTF-8"?>'
122  . '<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></page_layouts>';
123  }
124 
130  protected function _getIdAttributes()
131  {
132  return [
133  '/page_layouts/layout' => 'id'
134  ];
135  }
136 }
$label
Definition: details.phtml:21
$value
Definition: gender.phtml:16
__construct( $configFiles, \Magento\Framework\Config\DomFactory $domFactory, \Magento\Framework\Config\Dom\UrnResolver $urnResolver)
Definition: Config.php:27