Skip to content

Commit 9295fe6

Browse files
committed
AC-1077::Unable to pass data argument by di.xml for block instance
1 parent 8fb4d76 commit 9295fe6

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
class BlockFactory
1717
{
1818
/**
19-
* Object manager
20-
*
2119
* @var ObjectManagerInterface
2220
*/
2321
protected $objectManager;
@@ -38,10 +36,9 @@ class BlockFactory
3836
public function __construct(
3937
ObjectManagerInterface $objectManager,
4038
\Magento\Framework\ObjectManager\ConfigInterface $config
41-
)
42-
{
39+
) {
4340
$this->objectManager = $objectManager;
44-
$this->config = $config;
41+
$this->config = $config;
4542
}
4643

4744
/**
@@ -54,10 +51,14 @@ public function __construct(
5451
*/
5552
public function createBlock($blockName, array $arguments = [])
5653
{
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+
}
6162
}
6263
$block = $this->objectManager->create($blockName, $arguments);
6364
if (!$block instanceof BlockInterface) {

0 commit comments

Comments
 (0)