diff --git a/app/code/Magento/Backend/etc/adminhtml/di.xml b/app/code/Magento/Backend/etc/adminhtml/di.xml index 5154c4eb56c91..97a39139411c0 100644 --- a/app/code/Magento/Backend/etc/adminhtml/di.xml +++ b/app/code/Magento/Backend/etc/adminhtml/di.xml @@ -147,4 +147,9 @@ + + + Magento\Backend\Block\Template + + diff --git a/lib/internal/Magento/Framework/View/Layout/Generator/Block.php b/lib/internal/Magento/Framework/View/Layout/Generator/Block.php index d38c6b37fdd40..e995b2c20a6ab 100755 --- a/lib/internal/Magento/Framework/View/Layout/Generator/Block.php +++ b/lib/internal/Magento/Framework/View/Layout/Generator/Block.php @@ -7,6 +7,7 @@ use Magento\Framework\App\State; use Magento\Framework\ObjectManager\Config\Reader\Dom; +use Magento\Framework\View\Element\Template; use Magento\Framework\View\Layout; /** @@ -60,6 +61,13 @@ class Block implements Layout\GeneratorInterface */ protected $exceptionHandlerBlockFactory; + /** + * Default block class name. Will be used if no class name is specified in block configuration + * + * @var string + */ + private $defaultClass; + /** * @param \Magento\Framework\View\Element\BlockFactory $blockFactory * @param \Magento\Framework\Data\Argument\InterpreterInterface $argumentInterpreter @@ -69,6 +77,7 @@ class Block implements Layout\GeneratorInterface * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver * @param \Magento\Framework\View\Element\ExceptionHandlerBlockFactory $exceptionHandlerBlockFactory * @param State $appState + * @param string $defaultClass */ public function __construct( \Magento\Framework\View\Element\BlockFactory $blockFactory, @@ -78,7 +87,8 @@ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\ScopeResolverInterface $scopeResolver, \Magento\Framework\View\Element\ExceptionHandlerBlockFactory $exceptionHandlerBlockFactory, - State $appState + State $appState, + $defaultClass = Template::class ) { $this->blockFactory = $blockFactory; $this->argumentInterpreter = $argumentInterpreter; @@ -88,6 +98,7 @@ public function __construct( $this->scopeResolver = $scopeResolver; $this->exceptionHandlerBlockFactory = $exceptionHandlerBlockFactory; $this->appState = $appState; + $this->defaultClass = $defaultClass; } /** @@ -210,7 +221,8 @@ protected function generateBlock( } // create block - $className = $attributes['class']; + $className = isset($attributes['class']) && !empty($attributes['class']) ? + $attributes['class'] : $this->defaultClass ; $block = $this->createBlock($className, $elementName, [ 'data' => $this->evaluateArguments($data['arguments']) ]);