6
6
namespace Magento \Framework \View \Element ;
7
7
8
8
use Magento \Framework \ObjectManagerInterface ;
9
+ use Magento \Framework \ObjectManager \ConfigInterface ;
10
+ use Magento \Framework \App \ObjectManager ;
9
11
10
12
/**
11
13
* Creates Blocks
@@ -23,22 +25,23 @@ class BlockFactory
23
25
/**
24
26
* Object manager config
25
27
*
26
- * @var \Magento\Framework\ObjectManager\ ConfigInterface
28
+ * @var ConfigInterface
27
29
*/
28
30
private $ config ;
29
31
30
32
/**
31
33
* Constructor
32
34
*
33
35
* @param ObjectManagerInterface $objectManager
34
- * @param \Magento\Framework\ObjectManager\ ConfigInterface $config
36
+ * @param ConfigInterface $config
35
37
*/
36
38
public function __construct (
37
39
ObjectManagerInterface $ objectManager ,
38
- \ Magento \ Framework \ ObjectManager \ ConfigInterface $ config
40
+ ? ConfigInterface $ config = null
39
41
) {
40
42
$ this ->objectManager = $ objectManager ;
41
43
$ this ->config = $ config ;
44
+ $ this ->config = $ config ?: ObjectManager::getInstance ()->get (ConfigInterface::class);
42
45
}
43
46
44
47
/**
@@ -72,13 +75,13 @@ public function createBlock($blockName, array $arguments = [])
72
75
*/
73
76
private function getConfigArguments ($ blockName , array $ arguments = [])
74
77
{
78
+ if (!$ this ->config ) {
79
+ return $ arguments ;
80
+ }
75
81
$ configArguments = $ this ->config ->getArguments ($ blockName );
76
82
if ($ configArguments && isset ($ configArguments ['data ' ])) {
77
- if ($ arguments && isset ($ arguments ['data ' ])) {
78
- $ arguments ['data ' ] = array_merge ($ arguments ['data ' ], $ configArguments ['data ' ]);
79
- } else {
80
- $ arguments ['data ' ] = $ configArguments ['data ' ];
81
- }
83
+ $ arguments ['data ' ] = ($ arguments && isset ($ arguments ['data ' ])) ?
84
+ array_merge ($ arguments ['data ' ], $ configArguments ['data ' ]) : $ configArguments ['data ' ];
82
85
}
83
86
return $ arguments ;
84
87
}
0 commit comments