3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
6
7
7
- /**
8
- * Adminhtml dashboard totals bar
9
- *
10
- * @author Magento Core Team <[email protected] >
11
- */
12
8
namespace Magento \Backend \Block \Dashboard ;
13
9
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
+
14
17
/**
15
- * Totals block.
18
+ * Adminhtml dashboard totals bar
19
+ * @api
16
20
*/
17
- class Totals extends \ Magento \ Backend \ Block \ Dashboard \ Bar
21
+ class Totals extends Bar
18
22
{
19
23
/**
20
24
* @var string
21
25
*/
22
26
protected $ _template = 'Magento_Backend::dashboard/totalbar.phtml ' ;
23
27
24
28
/**
25
- * @var \Magento\Framework\Module\ Manager
29
+ * @var Manager
26
30
*/
27
31
protected $ _moduleManager ;
28
32
29
33
/**
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
33
37
* @param array $data
34
38
*/
35
39
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 ,
39
43
array $ data = []
40
44
) {
41
45
$ this ->_moduleManager = $ moduleManager ;
@@ -58,9 +62,9 @@ protected function _prepareLayout()
58
62
) || $ this ->getRequest ()->getParam (
59
63
'group '
60
64
);
61
- $ period = $ this ->getRequest ()->getParam ('period ' , ' 24h ' );
65
+ $ period = $ this ->getRequest ()->getParam ('period ' , Period:: PERIOD_24_HOURS );
62
66
63
- /* @var $collection \Magento\Reports\Model\ResourceModel\Order\ Collection */
67
+ /* @var $collection Collection */
64
68
$ collection = $ this ->_collectionFactory ->create ()->addCreateAtPeriodFilter (
65
69
$ period
66
70
)->calculateTotals (
@@ -80,7 +84,7 @@ protected function _prepareLayout()
80
84
} elseif (!$ collection ->isLive ()) {
81
85
$ collection ->addFieldToFilter (
82
86
'store_id ' ,
83
- ['eq ' => $ this ->_storeManager ->getStore (\ Magento \ Store \ Model \ Store::ADMIN_CODE )->getId ()]
87
+ ['eq ' => $ this ->_storeManager ->getStore (Store::ADMIN_CODE )->getId ()]
84
88
);
85
89
}
86
90
}
@@ -94,5 +98,7 @@ protected function _prepareLayout()
94
98
$ this ->addTotal (__ ('Tax ' ), $ totals ->getTax ());
95
99
$ this ->addTotal (__ ('Shipping ' ), $ totals ->getShipping ());
96
100
$ this ->addTotal (__ ('Quantity ' ), $ totals ->getQuantity () * 1 , true );
101
+
102
+ return $ this ;
97
103
}
98
104
}
0 commit comments