Skip to content

Commit a811bcf

Browse files
committed
AC-1077::Unable to pass data argument by di.xml for block instance
1 parent 5788e74 commit a811bcf

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

lib/internal/Magento/Framework/View/Element/BlockFactory.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,27 @@ class BlockFactory
2727
*
2828
* @param ObjectManagerInterface $objectManager
2929
*/
30-
public function __construct(ObjectManagerInterface $objectManager)
30+
31+
/**
32+
* Object manager config
33+
*
34+
* @var \Magento\Framework\ObjectManager\ConfigInterface
35+
*/
36+
protected $config;
37+
38+
/**
39+
* Constructor
40+
*
41+
* @param ObjectManagerInterface $objectManager
42+
* @param \Magento\Framework\ObjectManager\ConfigInterface $config
43+
*/
44+
public function __construct(
45+
ObjectManagerInterface $objectManager,
46+
\Magento\Framework\ObjectManager\ConfigInterface $config
47+
)
3148
{
3249
$this->objectManager = $objectManager;
50+
$this->config = $config;
3351
}
3452

3553
/**
@@ -43,6 +61,10 @@ public function __construct(ObjectManagerInterface $objectManager)
4361
public function createBlock($blockName, array $arguments = [])
4462
{
4563
$blockName = ltrim($blockName, '\\');
64+
$configArguments = $this->config->getArguments($blockName);
65+
if (isset($configArguments['data'])) {
66+
$arguments['data']+= $configArguments['data'];
67+
}
4668
$block = $this->objectManager->create($blockName, $arguments);
4769
if (!$block instanceof BlockInterface) {
4870
throw new \LogicException($blockName . ' does not implement BlockInterface');

0 commit comments

Comments
 (0)