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

Public Member Functions

 __construct (\Magento\Config\Model\Config\Structure\SearchInterface $configStructure, array $configPaths=[])
 
 toOptionArray ($withGroup=false)
 
 getData ()
 
- Public Member Functions inherited from OptionSourceInterface
 toOptionArray ()
 

Data Fields

const DEFAULT_VARIABLE_TYPE = "default"
 
const CUSTOM_VARIABLE_TYPE = "custom"
 

Detailed Description

Store Contact Information source model.

Definition at line 11 of file Variables.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Config\Model\Config\Structure\SearchInterface  $configStructure,
array  $configPaths = [] 
)

Constructor.

Parameters
\Magento\Config\Model\Config\Structure\SearchInterface$configStructure
array$configPaths

Definition at line 42 of file Variables.php.

45  {
46  $this->configStructure = $configStructure;
47  $this->configPaths = $configPaths;
48  }

Member Function Documentation

◆ getData()

getData ( )

Return available config variables.

Returns
array @codeCoverageIgnore

Definition at line 93 of file Variables.php.

94  {
95  return $this->getFlatConfigVars();
96  }

◆ toOptionArray()

toOptionArray (   $withGroup = false)

Retrieve option array of store contact variables.

Parameters
bool$withGroup
Returns
array

Definition at line 56 of file Variables.php.

57  {
58  $optionArray = [];
59  if ($withGroup) {
60  foreach ($this->getConfigVariables() as $configVariableGroup) {
61  $group = [
62  'label' => $configVariableGroup['label']
63  ];
64  $groupElements = [];
65  foreach ($configVariableGroup['elements'] as $element) {
66  $groupElements[] = [
67  'value' => '{{config path="' . $element['value'] . '"}}',
68  'label' => $element['label'],
69  ];
70  }
71  $group['value'] = $groupElements;
72  $optionArray[] = $group;
73  }
74  } else {
75  foreach ($this->getConfigVariables() as $configVariableGroup) {
76  foreach ($configVariableGroup['elements'] as $element) {
77  $optionArray[] = [
78  'value' => '{{config path="' . $element['value'] . '"}}',
79  'label' => $element['label'],
80  ];
81  }
82  }
83  }
84  return $optionArray;
85  }
$group
Definition: sections.phtml:16
$element
Definition: element.phtml:12

Field Documentation

◆ CUSTOM_VARIABLE_TYPE

const CUSTOM_VARIABLE_TYPE = "custom"

Definition at line 17 of file Variables.php.

◆ DEFAULT_VARIABLE_TYPE

const DEFAULT_VARIABLE_TYPE = "default"

Variable types

Definition at line 16 of file Variables.php.


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