Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Dashboard.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Backend\Block;
8 
14 {
18  const XML_PATH_ENABLE_CHARTS = 'admin/dashboard/enable_charts';
19 
23  protected $_template = 'Magento_Backend::dashboard/index.phtml';
24 
28  protected function _prepareLayout()
29  {
30  $this->addChild('lastOrders', \Magento\Backend\Block\Dashboard\Orders\Grid::class);
31 
32  $this->addChild('totals', \Magento\Backend\Block\Dashboard\Totals::class);
33 
34  $this->addChild('sales', \Magento\Backend\Block\Dashboard\Sales::class);
35 
36  $isChartEnabled = $this->_scopeConfig->getValue(
37  self::XML_PATH_ENABLE_CHARTS,
38  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
39  );
40  if ($isChartEnabled) {
41  $block = $this->getLayout()->createBlock(\Magento\Backend\Block\Dashboard\Diagrams::class);
42  } else {
43  $block = $this->getLayout()->createBlock(
44  \Magento\Backend\Block\Template::class
45  )->setTemplate(
46  'dashboard/graph/disabled.phtml'
47  )->setConfigUrl(
48  $this->getUrl(
49  'adminhtml/system_config/edit',
50  ['section' => 'admin', '_fragment' => 'admin_dashboard-link']
51  )
52  );
53  }
54  $this->setChild('diagrams', $block);
55 
56  $this->addChild('grids', \Magento\Backend\Block\Dashboard\Grids::class);
57 
58  parent::_prepareLayout();
59  }
60 
64  public function getSwitchUrl()
65  {
66  if ($url = $this->getData('switch_url')) {
67  return $url;
68  }
69  return $this->getUrl('adminhtml/*/*', ['_current' => true, 'period' => null]);
70  }
71 }
getData($key='', $index=null)
Definition: DataObject.php:119
$block
Definition: block.php:8