16
16
class BlockFactory
17
17
{
18
18
/**
19
- * Object manager
20
- *
21
19
* @var ObjectManagerInterface
22
20
*/
23
21
protected $ objectManager ;
@@ -38,10 +36,9 @@ class BlockFactory
38
36
public function __construct (
39
37
ObjectManagerInterface $ objectManager ,
40
38
\Magento \Framework \ObjectManager \ConfigInterface $ config
41
- )
42
- {
39
+ ) {
43
40
$ this ->objectManager = $ objectManager ;
44
- $ this ->config = $ config ;
41
+ $ this ->config = $ config ;
45
42
}
46
43
47
44
/**
@@ -54,10 +51,14 @@ public function __construct(
54
51
*/
55
52
public function createBlock ($ blockName , array $ arguments = [])
56
53
{
57
- $ blockName = ltrim ($ blockName , '\\' );
58
- $ configArguments = $ this ->config ->getArguments ($ blockName );
59
- if (isset ($ configArguments ['data ' ])) {
60
- $ arguments ['data ' ]+= $ configArguments ['data ' ];
54
+ $ blockName = ltrim ($ blockName , '\\' );
55
+ $ configArguments = $ this ->config ->getArguments ($ blockName );
56
+ if ($ configArguments != null && isset ($ configArguments ['data ' ])) {
57
+ if ($ arguments != null && isset ($ arguments ['data ' ])) {
58
+ $ arguments ['data ' ] = array_merge ($ arguments ['data ' ], $ configArguments ['data ' ]);
59
+ } else {
60
+ $ arguments ['data ' ] = $ configArguments ['data ' ];
61
+ }
61
62
}
62
63
$ block = $ this ->objectManager ->create ($ blockName , $ arguments );
63
64
if (!$ block instanceof BlockInterface) {
0 commit comments