8
8
use Magento \Config \Model \Config \Structure \Reader as ConfigStructureReader ;
9
9
use Magento \Framework \App \Area ;
10
10
use Magento \Framework \App \Config \ConfigSourceInterface ;
11
+ use Magento \Framework \App \ObjectManager ;
11
12
use Magento \Framework \DataObject ;
12
13
use Magento \Framework \App \Config \Initial \Reader as InitialConfigReader ;
13
14
@@ -31,14 +32,15 @@ class ModularConfigSource implements ConfigSourceInterface
31
32
32
33
/**
33
34
* @param InitialConfigReader $initialConfigReader
34
- * @param ConfigStructureReader $configStructureReader
35
+ * @param ConfigStructureReader|null $configStructureReader
35
36
*/
36
37
public function __construct (
37
38
InitialConfigReader $ initialConfigReader ,
38
- ConfigStructureReader $ configStructureReader
39
+ ? ConfigStructureReader $ configStructureReader = null
39
40
) {
40
41
$ this ->initialConfigReader = $ initialConfigReader ;
41
- $ this ->configStructureReader = $ configStructureReader ;
42
+ $ this ->configStructureReader = $ configStructureReader
43
+ ?? ObjectManager::getInstance ()->get (ConfigStructureReader::class);
42
44
}
43
45
44
46
/**
@@ -63,18 +65,6 @@ public function get($path = '')
63
65
return $ data ->getData ('data ' . $ path ) ?: [];
64
66
}
65
67
66
- private function addPathKey (array $ data , string $ path ): array
67
- {
68
- if (strpos ($ path , '/ ' ) !== false ) {
69
- list ($ key , $ subPath ) = explode ('/ ' , $ path , 2 );
70
- $ data [$ key ] = $ this ->addPathKey ($ data [$ key ] ?? [], $ subPath );
71
- } else {
72
- $ data += [$ path => null ];
73
- }
74
-
75
- return $ data ;
76
- }
77
-
78
68
/**
79
69
* Merge initial config with config structure
80
70
*
@@ -84,7 +74,7 @@ private function addPathKey(array $data, string $path): array
84
74
*/
85
75
private function merge (array $ config , array $ sections ): array
86
76
{
87
- foreach ($ sections as $ key => $ section ) {
77
+ foreach ($ sections as $ section ) {
88
78
if (isset ($ section ['children ' ])) {
89
79
$ config [$ section ['id ' ]] = $ this ->merge (
90
80
$ config [$ section ['id ' ]] ?? [],
0 commit comments