@@ -25,7 +25,7 @@ class BlockFactory
25
25
*
26
26
* @var \Magento\Framework\ObjectManager\ConfigInterface
27
27
*/
28
- protected $ config ;
28
+ private $ config ;
29
29
30
30
/**
31
31
* Constructor
@@ -51,16 +51,9 @@ public function __construct(
51
51
*/
52
52
public function createBlock ($ blockName , array $ arguments = [])
53
53
{
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
- }
62
- }
63
- $ block = $ this ->objectManager ->create ($ blockName , $ arguments );
54
+ $ blockName = ltrim ($ blockName , '\\' );
55
+ $ arguments = $ this ->getConfigArguments ($ blockName , $ arguments );
56
+ $ block = $ this ->objectManager ->create ($ blockName , $ arguments );
64
57
if (!$ block instanceof BlockInterface) {
65
58
throw new \LogicException ($ blockName . ' does not implement BlockInterface ' );
66
59
}
@@ -69,4 +62,24 @@ public function createBlock($blockName, array $arguments = [])
69
62
}
70
63
return $ block ;
71
64
}
65
+
66
+ /**
67
+ * Get All Config Arguments based on Block Name
68
+ *
69
+ * @param string $blockName
70
+ * @param array $arguments
71
+ * @return array $arguments
72
+ */
73
+ private function getConfigArguments ($ blockName , array $ arguments = [])
74
+ {
75
+ $ configArguments = $ this ->config ->getArguments ($ blockName );
76
+ 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
+ }
82
+ }
83
+ return $ arguments ;
84
+ }
72
85
}
0 commit comments