Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Container.php
Go to the documentation of this file.
1 <?php
8 
10 
19 {
27  protected function createButton($blockName, $blockClassName = null)
28  {
29  if (null === $blockClassName) {
30  $blockClassName = \Magento\Backend\Block\Widget\Button::class;
31  }
32  return $this->getLayout()->createBlock($blockClassName, $blockName);
33  }
34 
38  protected function _toHtml()
39  {
40  $item = $this->getButtonItem();
41  $context = $this->getContext();
42 
43  if ($item && $context && $context->canRender($item)) {
44  $data = $item->getData();
45  $blockClassName = isset($data['class_name']) ? $data['class_name'] : null;
46  $buttonName = $this->getContext()->getNameInLayout() . '-' . $item->getId() . '-button';
47  $block = $this->createButton($buttonName, $blockClassName);
48  $block->setData($data);
49  return $block->toHtml();
50  }
51  return parent::_toHtml();
52  }
53 }
createButton($blockName, $blockClassName=null)
Definition: Container.php:27
$block
Definition: block.php:8