<?php /** * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Backend\Controller\Adminhtml\Dashboard; class AjaxBlock extends \Magento\Backend\Controller\Adminhtml\Dashboard { /** * @var \Magento\Framework\Controller\Result\RawFactory */ protected $resultRawFactory; /** * @var \Magento\Framework\View\LayoutFactory */ protected $layoutFactory; /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory, \Magento\Framework\View\LayoutFactory $layoutFactory ) { parent::__construct($context); $this->resultRawFactory = $resultRawFactory; $this->layoutFactory = $layoutFactory; } /** * @return \Magento\Framework\Controller\Result\Raw */ public function execute() { $output = ''; $blockTab = $this->getRequest()->getParam('block'); $blockClassSuffix = str_replace( ' ', '\\', ucwords(str_replace('_', ' ', $blockTab)) ); if (in_array($blockTab, ['tab_orders', 'tab_amounts', 'totals'])) { $output = $this->layoutFactory->create() ->createBlock('Magento\\Backend\\Block\\Dashboard\\' . $blockClassSuffix) ->toHtml(); } /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */ $resultRaw = $this->resultRawFactory->create(); return $resultRaw->setContents($output); } }