Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AjaxBlock.php
Go to the documentation of this file.
1 <?php
8 
10 {
14  protected $resultRawFactory;
15 
19  protected $layoutFactory;
20 
26  public function __construct(
27  \Magento\Backend\App\Action\Context $context,
28  \Magento\Framework\Controller\Result\RawFactory $resultRawFactory,
29  \Magento\Framework\View\LayoutFactory $layoutFactory
30  ) {
31  parent::__construct($context);
32  $this->resultRawFactory = $resultRawFactory;
33  $this->layoutFactory = $layoutFactory;
34  }
35 
39  public function execute()
40  {
41  $output = '';
42  $blockTab = $this->getRequest()->getParam('block');
43  $blockClassSuffix = str_replace(
44  ' ',
45  '\\',
46  ucwords(str_replace('_', ' ', $blockTab))
47  );
48  if (in_array($blockTab, ['tab_orders', 'tab_amounts', 'totals'])) {
49  $output = $this->layoutFactory->create()
50  ->createBlock('Magento\\Backend\\Block\\Dashboard\\' . $blockClassSuffix)
51  ->toHtml();
52  }
54  $resultRaw = $this->resultRawFactory->create();
55  return $resultRaw->setContents($output);
56  }
57 }
__construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory, \Magento\Framework\View\LayoutFactory $layoutFactory)
Definition: AjaxBlock.php:26