Skip to content

Commit 1a5d380

Browse files
committed
MAGETWO-90864: Media Gallery content is not showing when secure keys are enabled
Move Config::parseAdditionalData to Converter
1 parent 4e410b8 commit 1a5d380

File tree

2 files changed

+56
-49
lines changed

2 files changed

+56
-49
lines changed

app/code/Magento/PageBuilder/Model/Config.php

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,38 @@
99
namespace Magento\PageBuilder\Model;
1010

1111
use Magento\Framework\App\Config\ScopeConfigInterface;
12-
use Magento\Framework\Data\Argument\InterpreterInterface;
13-
use Magento\PageBuilder\Model\Config\ContentType\AdditionalData\ProviderInterface;
12+
use Magento\PageBuilder\Model\Config\ContentType\Converter;
1413

1514
class Config extends \Magento\Framework\Config\Data implements \Magento\PageBuilder\Model\Config\ConfigInterface
1615
{
1716
const IS_PAGEBUILDER_ENABLED = 'cms/pagebuilder/enabled';
1817

1918
/**
20-
* @var InterpreterInterface
19+
* @var ScopeConfigInterface
2120
*/
22-
private $argumentInterpreter;
21+
private $scopeConfig;
2322

2423
/**
25-
* @var ScopeConfigInterface
24+
* @var Converter
2625
*/
27-
private $scopeConfig;
26+
private $converter;
2827

2928
/**
3029
* @param \Magento\PageBuilder\Model\Config\CompositeReader $reader
3130
* @param \Magento\Framework\Config\CacheInterface $cache
3231
* @param ScopeConfigInterface $scopeConfig
33-
* @param InterpreterInterface $argumentInterpreter
32+
* @param Converter $converter
3433
* @param string $cacheId
3534
*/
3635
public function __construct(
3736
\Magento\PageBuilder\Model\Config\CompositeReader $reader,
3837
\Magento\Framework\Config\CacheInterface $cache,
3938
ScopeConfigInterface $scopeConfig,
40-
InterpreterInterface $argumentInterpreter,
39+
Converter $converter,
4140
$cacheId = 'pagebuilder_config'
4241
) {
4342
$this->scopeConfig = $scopeConfig;
44-
$this->argumentInterpreter = $argumentInterpreter;
43+
$this->converter = $converter;
4544
parent::__construct($reader, $cache, $cacheId);
4645
}
4746

@@ -61,7 +60,7 @@ public function getGroups()
6160
public function getContentTypes(): array
6261
{
6362
$types = $this->get('types');
64-
$types = $this->parseAdditionalData($types);
63+
$types = $this->converter->parseAdditionalData($types);
6564

6665
return $types;
6766
}
@@ -77,42 +76,4 @@ public function isEnabled(): bool
7776
\Magento\PageBuilder\Model\Config::IS_PAGEBUILDER_ENABLED
7877
);
7978
}
80-
81-
/**
82-
* Convert and evaluate additional data from arguments nodes to array
83-
*
84-
* @param array $types
85-
* @return array
86-
*/
87-
private function parseAdditionalData(array $types): array
88-
{
89-
$convertToProviders = function ($additionalDatum) use (&$convertToProviders) {
90-
$processedData = [];
91-
92-
foreach ($additionalDatum as $key => $value) {
93-
if (is_array($value)) {
94-
$processedData[$key] = $convertToProviders($additionalDatum[$key]);
95-
} elseif (is_object($value) && $value instanceof ProviderInterface) {
96-
$processedData[$key] = $value->getData($key)[$key];
97-
} else {
98-
$processedData[$key] = $value;
99-
}
100-
}
101-
102-
return $processedData;
103-
};
104-
105-
foreach ($types as &$type) {
106-
if (!isset($type['additional_data'])) {
107-
continue;
108-
}
109-
110-
foreach ($type['additional_data'] as &$additionalDatum) {
111-
$additionalDatum = $this->argumentInterpreter->evaluate($additionalDatum);
112-
$additionalDatum = $convertToProviders($additionalDatum);
113-
}
114-
}
115-
116-
return $types;
117-
}
11879
}

app/code/Magento/PageBuilder/Model/Config/ContentType/Converter.php

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,22 @@ class Converter implements \Magento\Framework\Config\ConverterInterface
1919
*/
2020
private $parser;
2121

22+
/**
23+
* @var InterpreterInterface
24+
*/
25+
private $argumentInterpreter;
26+
2227
/**
2328
* Converter constructor.
2429
* @param ArgumentParser $parser
30+
* @param InterpreterInterface $argumentInterpreter
2531
*/
2632
public function __construct(
27-
ArgumentParser $parser
33+
ArgumentParser $parser,
34+
InterpreterInterface $argumentInterpreter
2835
) {
2936
$this->parser = $parser;
37+
$this->argumentInterpreter = $argumentInterpreter;
3038
}
3139

3240
/**
@@ -43,6 +51,44 @@ public function convert($source): array
4351
];
4452
}
4553

54+
/**
55+
* Convert and evaluate additional data from arguments nodes to array
56+
*
57+
* @param array $types
58+
* @return array
59+
*/
60+
public function parseAdditionalData(array $types): array
61+
{
62+
$convertToProviders = function ($additionalDatum) use (&$convertToProviders) {
63+
$processedData = [];
64+
65+
foreach ($additionalDatum as $key => $value) {
66+
$processedData[$key] = $value;
67+
68+
if (is_array($value)) {
69+
$processedData[$key] = $convertToProviders($additionalDatum[$key]);
70+
} elseif (is_object($value) && $value instanceof ProviderInterface) {
71+
$processedData[$key] = $value->getData($key)[$key];
72+
}
73+
}
74+
75+
return $processedData;
76+
};
77+
78+
foreach ($types as &$type) {
79+
if (!isset($type['additional_data'])) {
80+
continue;
81+
}
82+
83+
foreach ($type['additional_data'] as &$additionalDatum) {
84+
$additionalDatum = $this->argumentInterpreter->evaluate($additionalDatum);
85+
$additionalDatum = $convertToProviders($additionalDatum);
86+
}
87+
}
88+
89+
return $types;
90+
}
91+
4692
/**
4793
* Convert types
4894
*

0 commit comments

Comments
 (0)