33 * Copyright © Magento, Inc. All rights reserved.
44 * See COPYING.txt for license details.
55 */
6+ declare (strict_types=1 );
67
7- /**
8- * Adminhtml dashboard totals bar
9- *
10- * @author Magento Core Team <core@magentocommerce.com>
11- */
128namespace Magento \Backend \Block \Dashboard ;
139
10+ use Magento \Backend \Block \Template \Context ;
11+ use Magento \Backend \Model \Dashboard \Period ;
12+ use Magento \Framework \Module \Manager ;
13+ use Magento \Reports \Model \ResourceModel \Order \Collection ;
14+ use Magento \Reports \Model \ResourceModel \Order \CollectionFactory ;
15+ use Magento \Store \Model \Store ;
16+
1417/**
15- * Totals block.
18+ * Adminhtml dashboard totals bar
19+ * @api
1620 */
17- class Totals extends \ Magento \ Backend \ Block \ Dashboard \ Bar
21+ class Totals extends Bar
1822{
1923 /**
2024 * @var string
2125 */
2226 protected $ _template = 'Magento_Backend::dashboard/totalbar.phtml ' ;
2327
2428 /**
25- * @var \Magento\Framework\Module\ Manager
29+ * @var Manager
2630 */
2731 protected $ _moduleManager ;
2832
2933 /**
30- * @param \Magento\Backend\Block\Template\ Context $context
31- * @param \Magento\Reports\Model\ResourceModel\Order\ CollectionFactory $collectionFactory
32- * @param \Magento\Framework\Module\ Manager $moduleManager
34+ * @param Context $context
35+ * @param CollectionFactory $collectionFactory
36+ * @param Manager $moduleManager
3337 * @param array $data
3438 */
3539 public function __construct (
36- \ Magento \ Backend \ Block \ Template \ Context $ context ,
37- \ Magento \ Reports \ Model \ ResourceModel \ Order \ CollectionFactory $ collectionFactory ,
38- \ Magento \ Framework \ Module \ Manager $ moduleManager ,
40+ Context $ context ,
41+ CollectionFactory $ collectionFactory ,
42+ Manager $ moduleManager ,
3943 array $ data = []
4044 ) {
4145 $ this ->_moduleManager = $ moduleManager ;
@@ -58,9 +62,9 @@ protected function _prepareLayout()
5862 ) || $ this ->getRequest ()->getParam (
5963 'group '
6064 );
61- $ period = $ this ->getRequest ()->getParam ('period ' , ' 24h ' );
65+ $ period = $ this ->getRequest ()->getParam ('period ' , Period:: PERIOD_24_HOURS );
6266
63- /* @var $collection \Magento\Reports\Model\ResourceModel\Order\ Collection */
67+ /* @var $collection Collection */
6468 $ collection = $ this ->_collectionFactory ->create ()->addCreateAtPeriodFilter (
6569 $ period
6670 )->calculateTotals (
@@ -80,7 +84,7 @@ protected function _prepareLayout()
8084 } elseif (!$ collection ->isLive ()) {
8185 $ collection ->addFieldToFilter (
8286 'store_id ' ,
83- ['eq ' => $ this ->_storeManager ->getStore (\ Magento \ Store \ Model \ Store::ADMIN_CODE )->getId ()]
87+ ['eq ' => $ this ->_storeManager ->getStore (Store::ADMIN_CODE )->getId ()]
8488 );
8589 }
8690 }
@@ -94,5 +98,7 @@ protected function _prepareLayout()
9498 $ this ->addTotal (__ ('Tax ' ), $ totals ->getTax ());
9599 $ this ->addTotal (__ ('Shipping ' ), $ totals ->getShipping ());
96100 $ this ->addTotal (__ ('Quantity ' ), $ totals ->getQuantity () * 1 , true );
101+
102+ return $ this ;
97103 }
98104}
0 commit comments