Skip to content

Commit e9b9a6a

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-88176' into 2.3-develop-pr8
2 parents 06ecd5c + 70b101d commit e9b9a6a

File tree

2 files changed

+19
-2
lines changed
  • app/code/Magento/Backend/etc/adminhtml
  • lib/internal/Magento/Framework/View/Layout/Generator

2 files changed

+19
-2
lines changed

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,9 @@
159159
</argument>
160160
</arguments>
161161
</type>
162+
<type name="Magento\Framework\View\Layout\Generator\Block">
163+
<arguments>
164+
<argument name="defaultClass" xsi:type="string">Magento\Backend\Block\Template</argument>
165+
</arguments>
166+
</type>
162167
</config>

lib/internal/Magento/Framework/View/Layout/Generator/Block.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Framework\App\State;
99
use Magento\Framework\ObjectManager\Config\Reader\Dom;
10+
use Magento\Framework\View\Element\Template;
1011
use Magento\Framework\View\Layout;
1112

1213
/**
@@ -60,6 +61,13 @@ class Block implements Layout\GeneratorInterface
6061
*/
6162
protected $exceptionHandlerBlockFactory;
6263

64+
/**
65+
* Default block class name. Will be used if no class name is specified in block configuration.
66+
*
67+
* @var string
68+
*/
69+
private $defaultClass;
70+
6371
/**
6472
* @param \Magento\Framework\View\Element\BlockFactory $blockFactory
6573
* @param \Magento\Framework\Data\Argument\InterpreterInterface $argumentInterpreter
@@ -69,6 +77,7 @@ class Block implements Layout\GeneratorInterface
6977
* @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver
7078
* @param \Magento\Framework\View\Element\ExceptionHandlerBlockFactory $exceptionHandlerBlockFactory
7179
* @param State $appState
80+
* @param string $defaultClass
7281
*/
7382
public function __construct(
7483
\Magento\Framework\View\Element\BlockFactory $blockFactory,
@@ -78,7 +87,8 @@ public function __construct(
7887
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
7988
\Magento\Framework\App\ScopeResolverInterface $scopeResolver,
8089
\Magento\Framework\View\Element\ExceptionHandlerBlockFactory $exceptionHandlerBlockFactory,
81-
State $appState
90+
State $appState,
91+
$defaultClass = Template::class
8292
) {
8393
$this->blockFactory = $blockFactory;
8494
$this->argumentInterpreter = $argumentInterpreter;
@@ -88,6 +98,7 @@ public function __construct(
8898
$this->scopeResolver = $scopeResolver;
8999
$this->exceptionHandlerBlockFactory = $exceptionHandlerBlockFactory;
90100
$this->appState = $appState;
101+
$this->defaultClass = $defaultClass;
91102
}
92103

93104
/**
@@ -210,7 +221,8 @@ protected function generateBlock(
210221
}
211222

212223
// create block
213-
$className = $attributes['class'];
224+
$className = isset($attributes['class']) && !empty($attributes['class']) ?
225+
$attributes['class'] : $this->defaultClass;
214226
$block = $this->createBlock($className, $elementName, [
215227
'data' => $this->evaluateArguments($data['arguments'])
216228
]);

0 commit comments

Comments
 (0)