File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed
lib/internal/Magento/Framework/App Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -28,19 +28,28 @@ public function convert($source)
28
28
/**
29
29
* Set array value by path
30
30
*
31
- * @param array $output
31
+ * @param array $container
32
32
* @param string $path
33
33
* @param string $value
34
34
* @return array
35
35
*/
36
- protected function _setArrayValue (array $ output , $ path , $ value )
36
+ protected function _setArrayValue (array $ container , $ path , $ value )
37
37
{
38
- $ parts = array_reverse ( explode ('/ ' , $ path) );
38
+ $ parts = explode ('/ ' , $ path );
39
39
40
- $ result = $ value ;
41
- foreach ($ parts as $ part ) {
42
- $ result = [$ part => $ result ];
40
+ if (count ($ parts ) > 0 ) {
41
+ $ parts = array_reverse ($ parts );
42
+
43
+ $ result = $ value ;
44
+ foreach ($ parts as $ part ) {
45
+ $ part = trim ($ part );
46
+ if ($ part !== '' ) {
47
+ $ result = [$ part => $ result ];
48
+ }
49
+ }
50
+
51
+ $ container = array_merge_recursive ($ container , $ result );
43
52
}
44
- return array_merge_recursive ( $ output , $ result ) ;
53
+ return $ container ;
45
54
}
46
55
}
Original file line number Diff line number Diff line change @@ -25,13 +25,17 @@ public function testConvert()
25
25
'some/config/path2 ' => 'value2 ' ,
26
26
'some/config/path2 ' => 'value3 ' ,
27
27
'some2/config/path2 ' => 'value4 ' ,
28
+ 'some/bad/path//// ' => 'value5 ' ,
28
29
];
29
30
$ expectedResult = [
30
31
'some ' => [
31
32
'config ' => [
32
33
'path1 ' => 'value1 ' ,
33
34
'path2 ' => 'value3 ' ,
34
- ]
35
+ ],
36
+ 'bad ' => [
37
+ 'path ' => 'value5 ' ,
38
+ ],
35
39
],
36
40
'some2 ' => [
37
41
'config ' => [
You can’t perform that action at this time.
0 commit comments