66namespace Magento \Framework \View \Element ;
77
88use Magento \Framework \ObjectManagerInterface ;
9+ use Magento \Framework \ObjectManager \ConfigInterface ;
10+ use Magento \Framework \App \ObjectManager ;
911
1012/**
1113 * Creates Blocks
@@ -23,22 +25,23 @@ class BlockFactory
2325 /**
2426 * Object manager config
2527 *
26- * @var \Magento\Framework\ObjectManager\ ConfigInterface
28+ * @var ConfigInterface
2729 */
2830 private $ config ;
2931
3032 /**
3133 * Constructor
3234 *
3335 * @param ObjectManagerInterface $objectManager
34- * @param \Magento\Framework\ObjectManager\ ConfigInterface $config
36+ * @param ConfigInterface $config
3537 */
3638 public function __construct (
3739 ObjectManagerInterface $ objectManager ,
38- \ Magento \ Framework \ ObjectManager \ ConfigInterface $ config
40+ ? ConfigInterface $ config = null
3941 ) {
4042 $ this ->objectManager = $ objectManager ;
4143 $ this ->config = $ config ;
44+ $ this ->config = $ config ?: ObjectManager::getInstance ()->get (ConfigInterface::class);
4245 }
4346
4447 /**
@@ -72,13 +75,13 @@ public function createBlock($blockName, array $arguments = [])
7275 */
7376 private function getConfigArguments ($ blockName , array $ arguments = [])
7477 {
78+ if (!$ this ->config ) {
79+ return $ arguments ;
80+ }
7581 $ configArguments = $ this ->config ->getArguments ($ blockName );
7682 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 ' ];
8285 }
8386 return $ arguments ;
8487 }
0 commit comments