Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Layout.php
Go to the documentation of this file.
1 <?php
7 
9 {
13  protected $_config;
14 
18  public function __construct(\Magento\Theme\Model\Layout\Config $config)
19  {
20  $this->_config = $config;
21  }
22 
28  protected $_options = null;
29 
34  protected $_defaultValue = null;
35 
41  public function getOptions()
42  {
43  if ($this->_options === null) {
44  $this->_options = [];
45  foreach ($this->_config->getPageLayouts() as $layout) {
46  $this->_options[$layout->getCode()] = $layout->getLabel();
47  if ($layout->getIsDefault()) {
48  $this->_defaultValue = $layout->getCode();
49  }
50  }
51  }
52 
53  return $this->_options;
54  }
55 
62  public function toOptionArray($withEmpty = false)
63  {
64  $options = [];
65 
66  foreach ($this->getOptions() as $value => $label) {
67  $options[] = ['label' => $label, 'value' => $value];
68  }
69 
70  if ($withEmpty) {
71  array_unshift($options, ['value' => '', 'label' => __('-- Please Select --')]);
72  }
73 
74  return $options;
75  }
76 
81  public function getDefaultValue()
82  {
83  $this->getOptions();
84  return $this->_defaultValue;
85  }
86 }
__construct(\Magento\Theme\Model\Layout\Config $config)
Definition: Layout.php:18
$config
Definition: fraud_order.php:17
__()
Definition: __.php:13
$label
Definition: details.phtml:21
$value
Definition: gender.phtml:16