Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Layout Class Reference
Inheritance diagram for Layout:
ArrayInterface OptionSourceInterface

Public Member Functions

 __construct (\Magento\Theme\Model\Layout\Config $config)
 
 getOptions ()
 
 toOptionArray ($withEmpty=false)
 
 getDefaultValue ()
 
- Public Member Functions inherited from OptionSourceInterface
 toOptionArray ()
 

Protected Attributes

 $_config
 
 $_options = null
 
 $_defaultValue = null
 

Detailed Description

Definition at line 8 of file Layout.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Theme\Model\Layout\Config  $config)
Parameters
\Magento\Theme\Model\Layout\Config$config

Definition at line 18 of file Layout.php.

19  {
20  $this->_config = $config;
21  }
$config
Definition: fraud_order.php:17

Member Function Documentation

◆ getDefaultValue()

getDefaultValue ( )

Default options value getter

Returns
string

Definition at line 81 of file Layout.php.

◆ getOptions()

getOptions ( )

Retrieve page layout options

Returns
array

Definition at line 41 of file Layout.php.

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  }

◆ toOptionArray()

toOptionArray (   $withEmpty = false)

Retrieve page layout options array

Parameters
bool$withEmpty
Returns
array

Definition at line 62 of file Layout.php.

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  }
__()
Definition: __.php:13
$label
Definition: details.phtml:21
$value
Definition: gender.phtml:16

Field Documentation

◆ $_config

$_config
protected

Definition at line 13 of file Layout.php.

◆ $_defaultValue

$_defaultValue = null
protected

Definition at line 34 of file Layout.php.

◆ $_options

$_options = null
protected

Definition at line 28 of file Layout.php.


The documentation for this class was generated from the following file: