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
/**
8
9
* Sales report admin controller
13
14
14
15
/**
15
16
* @SuppressWarnings(PHPMD.NumberOfChildren)
17
+ * phpcs:disable Magento2.Classes.AbstractApi
16
18
* @api
17
19
* @since 100.0.2
18
20
*/
@@ -37,31 +39,23 @@ public function _initAction()
37
39
*/
38
40
protected function _isAllowed ()
39
41
{
40
- switch ($ this ->getRequest ()->getActionName ()) {
41
- case 'sales ' :
42
- return $ this ->_authorization ->isAllowed ('Magento_Reports::salesroot_sales ' );
43
- break ;
44
- case 'tax ' :
45
- return $ this ->_authorization ->isAllowed ('Magento_Reports::tax ' );
46
- break ;
47
- case 'shipping ' :
48
- return $ this ->_authorization ->isAllowed ('Magento_Reports::shipping ' );
49
- break ;
50
- case 'invoiced ' :
51
- return $ this ->_authorization ->isAllowed ('Magento_Reports::invoiced ' );
52
- break ;
53
- case 'refunded ' :
54
- return $ this ->_authorization ->isAllowed ('Magento_Reports::refunded ' );
55
- break ;
56
- case 'coupons ' :
57
- return $ this ->_authorization ->isAllowed ('Magento_Reports::coupons ' );
58
- break ;
59
- case 'bestsellers ' :
60
- return $ this ->_authorization ->isAllowed ('Magento_Reports::bestsellers ' );
61
- break ;
62
- default :
63
- return $ this ->_authorization ->isAllowed ('Magento_Reports::salesroot ' );
64
- break ;
65
- }
42
+ return match (strtolower ($ this ->getRequest ()->getActionName ())) {
43
+ 'exportsalescsv ' , 'exportsalesexcel ' , 'sales ' =>
44
+ $ this ->_authorization ->isAllowed ('Magento_Reports::salesroot_sales ' ),
45
+ 'exporttaxcsv ' , 'exporttaxexcel ' , 'tax ' =>
46
+ $ this ->_authorization ->isAllowed ('Magento_Reports::tax ' ),
47
+ 'exportshippingcsv ' , 'exportshippingexcel ' , 'shipping ' =>
48
+ $ this ->_authorization ->isAllowed ('Magento_Reports::shipping ' ),
49
+ 'exportinvoicedcsv ' , 'exportinvoicedexcel ' , 'invoiced ' =>
50
+ $ this ->_authorization ->isAllowed ('Magento_Reports::invoiced ' ),
51
+ 'exportrefundedcsv ' , 'exportrefundedexcel ' , 'refunded ' =>
52
+ $ this ->_authorization ->isAllowed ('Magento_Reports::refunded ' ),
53
+ 'exportcouponscsv ' , 'exportcouponsexcel ' , 'coupons ' =>
54
+ $ this ->_authorization ->isAllowed ('Magento_Reports::coupons ' ),
55
+ 'exportbestsellerscsv ' , 'exportbestsellersexcel ' , 'bestsellers ' =>
56
+ $ this ->_authorization ->isAllowed ('Magento_Reports::bestsellers ' ),
57
+ default =>
58
+ $ this ->_authorization ->isAllowed ('Magento_Reports::salesroot ' ),
59
+ };
66
60
}
67
61
}
0 commit comments