9
9
namespace Magento \PageBuilder \Model ;
10
10
11
11
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 ;
14
13
15
14
class Config extends \Magento \Framework \Config \Data implements \Magento \PageBuilder \Model \Config \ConfigInterface
16
15
{
17
16
const IS_PAGEBUILDER_ENABLED = 'cms/pagebuilder/enabled ' ;
18
17
19
18
/**
20
- * @var InterpreterInterface
19
+ * @var ScopeConfigInterface
21
20
*/
22
- private $ argumentInterpreter ;
21
+ private $ scopeConfig ;
23
22
24
23
/**
25
- * @var ScopeConfigInterface
24
+ * @var Converter
26
25
*/
27
- private $ scopeConfig ;
26
+ private $ converter ;
28
27
29
28
/**
30
29
* @param \Magento\PageBuilder\Model\Config\CompositeReader $reader
31
30
* @param \Magento\Framework\Config\CacheInterface $cache
32
31
* @param ScopeConfigInterface $scopeConfig
33
- * @param InterpreterInterface $argumentInterpreter
32
+ * @param Converter $converter
34
33
* @param string $cacheId
35
34
*/
36
35
public function __construct (
37
36
\Magento \PageBuilder \Model \Config \CompositeReader $ reader ,
38
37
\Magento \Framework \Config \CacheInterface $ cache ,
39
38
ScopeConfigInterface $ scopeConfig ,
40
- InterpreterInterface $ argumentInterpreter ,
39
+ Converter $ converter ,
41
40
$ cacheId = 'pagebuilder_config '
42
41
) {
43
42
$ this ->scopeConfig = $ scopeConfig ;
44
- $ this ->argumentInterpreter = $ argumentInterpreter ;
43
+ $ this ->converter = $ converter ;
45
44
parent ::__construct ($ reader , $ cache , $ cacheId );
46
45
}
47
46
@@ -61,7 +60,7 @@ public function getGroups()
61
60
public function getContentTypes (): array
62
61
{
63
62
$ types = $ this ->get ('types ' );
64
- $ types = $ this ->parseAdditionalData ($ types );
63
+ $ types = $ this ->converter -> parseAdditionalData ($ types );
65
64
66
65
return $ types ;
67
66
}
@@ -77,42 +76,4 @@ public function isEnabled(): bool
77
76
\Magento \PageBuilder \Model \Config::IS_PAGEBUILDER_ENABLED
78
77
);
79
78
}
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
- }
118
79
}
0 commit comments