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 ;
11
9
12
10
/**
13
11
* Creates Blocks
@@ -22,25 +20,14 @@ class BlockFactory
22
20
*/
23
21
protected $ objectManager ;
24
22
25
- /**
26
- * Object manager config
27
- *
28
- * @var ConfigInterface
29
- */
30
- private $ config ;
31
-
32
23
/**
33
24
* Constructor
34
25
*
35
26
* @param ObjectManagerInterface $objectManager
36
- * @param ConfigInterface $config
37
27
*/
38
- public function __construct (
39
- ObjectManagerInterface $ objectManager ,
40
- ?ConfigInterface $ config = null
41
- ) {
28
+ public function __construct (ObjectManagerInterface $ objectManager )
29
+ {
42
30
$ this ->objectManager = $ objectManager ;
43
- $ this ->config = $ config ?: ObjectManager::getInstance ()->get (ConfigInterface::class);
44
31
}
45
32
46
33
/**
@@ -53,9 +40,8 @@ public function __construct(
53
40
*/
54
41
public function createBlock ($ blockName , array $ arguments = [])
55
42
{
56
- $ blockName = ltrim ($ blockName , '\\' );
57
- $ arguments = $ this ->getConfigArguments ($ blockName , $ arguments );
58
- $ block = $ this ->objectManager ->create ($ blockName , $ arguments );
43
+ $ blockName = ltrim ($ blockName , '\\' );
44
+ $ block = $ this ->objectManager ->create ($ blockName , $ arguments );
59
45
if (!$ block instanceof BlockInterface) {
60
46
throw new \LogicException ($ blockName . ' does not implement BlockInterface ' );
61
47
}
@@ -64,24 +50,4 @@ public function createBlock($blockName, array $arguments = [])
64
50
}
65
51
return $ block ;
66
52
}
67
-
68
- /**
69
- * Get All Config Arguments based on Block Name
70
- *
71
- * @param string $blockName
72
- * @param array $arguments
73
- * @return array $arguments
74
- */
75
- private function getConfigArguments ($ blockName , array $ arguments = [])
76
- {
77
- if (!$ this ->config ) {
78
- return $ arguments ;
79
- }
80
- $ configArguments = $ this ->config ->getArguments ($ blockName );
81
- if ($ configArguments && isset ($ configArguments ['data ' ])) {
82
- $ arguments ['data ' ] = ($ arguments && isset ($ arguments ['data ' ])) ?
83
- array_merge ($ arguments ['data ' ], $ configArguments ['data ' ]) : $ configArguments ['data ' ];
84
- }
85
- return $ arguments ;
86
- }
87
53
}
0 commit comments