24 private $configVariables = [];
29 private $configPaths = [];
34 private $configStructure;
43 \
Magento\Config\Model\Config\Structure\SearchInterface $configStructure,
44 array $configPaths = []
46 $this->configStructure = $configStructure;
47 $this->configPaths = $configPaths;
60 foreach ($this->getConfigVariables() as $configVariableGroup) {
62 'label' => $configVariableGroup[
'label']
65 foreach ($configVariableGroup[
'elements'] as
$element) {
67 'value' =>
'{{config path="' .
$element[
'value'] .
'"}}',
71 $group[
'value'] = $groupElements;
75 foreach ($this->getConfigVariables() as $configVariableGroup) {
76 foreach ($configVariableGroup[
'elements'] as
$element) {
78 'value' =>
'{{config path="' .
$element[
'value'] .
'"}}',
95 return $this->getFlatConfigVars();
103 private function getFlatConfigVars()
106 foreach ($this->getConfigVariables() as $configVariableGroup) {
107 foreach ($configVariableGroup[
'elements'] as
$element) {
108 $element[
'group_label'] = $configVariableGroup[
'label'];
120 private function getConfigVariables()
122 if (empty($this->configVariables)) {
123 foreach ($this->configPaths as $groupPath => $groupElements) {
124 $groupPathElements = explode(
'/', $groupPath);
127 foreach ($groupPathElements as $groupPathElement) {
128 $path[] = $groupPathElement;
130 $this->configStructure->getElementByConfigPath(implode(
'/',
$path))->getLabel()
133 $this->configVariables[$groupPath][
'label'] = implode(
' / ', $labels);
134 foreach (array_keys($groupElements) as $elementPath) {
135 $this->configVariables[$groupPath][
'elements'][] = [
136 'value' => $elementPath,
137 'label' =>
__($this->configStructure->getElementByConfigPath($elementPath)->getLabel()),
143 return $this->configVariables;
__construct(\Magento\Config\Model\Config\Structure\SearchInterface $configStructure, array $configPaths=[])
toOptionArray($withGroup=false)
const CUSTOM_VARIABLE_TYPE
const DEFAULT_VARIABLE_TYPE