Skip to content

Commit 61ff9a0

Browse files
committed
Merge remote-tracking branch 'origin/2.4.8-beta1-develop' into Sync-Minor-2.4.8-Beta1_v1
2 parents fa78515 + 53339d4 commit 61ff9a0

File tree

4 files changed

+55
-33
lines changed

4 files changed

+55
-33
lines changed

app/code/Magento/Reports/Controller/Adminhtml/Report/Customer.php

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,38 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
/**
89
*
910
* Customer reports admin controller
1011
*
11-
* @author Magento Core Team <core@magentocommerce.com>
1212
*/
1313
namespace Magento\Reports\Controller\Adminhtml\Report;
1414

15+
use Magento\Backend\App\Action;
16+
use Magento\Backend\App\Action\Context;
17+
use Magento\Framework\App\Response\Http\FileFactory;
18+
1519
/**
20+
* phpcs:disable Magento2.Classes.AbstractApi
1621
* @api
1722
* @since 100.0.2
1823
*/
19-
abstract class Customer extends \Magento\Backend\App\Action
24+
abstract class Customer extends Action
2025
{
2126
/**
22-
* @var \Magento\Framework\App\Response\Http\FileFactory
27+
* @var FileFactory
2328
*/
2429
protected $_fileFactory;
2530

2631
/**
27-
* @param \Magento\Backend\App\Action\Context $context
28-
* @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
32+
* @param Context $context
33+
* @param FileFactory $fileFactory
2934
*/
3035
public function __construct(
31-
\Magento\Backend\App\Action\Context $context,
32-
\Magento\Framework\App\Response\Http\FileFactory $fileFactory
36+
Context $context,
37+
FileFactory $fileFactory
3338
) {
3439
$this->_fileFactory = $fileFactory;
3540
parent::__construct($context);
@@ -60,19 +65,15 @@ public function _initAction()
6065
*/
6166
protected function _isAllowed()
6267
{
63-
switch ($this->getRequest()->getActionName()) {
64-
case 'accounts':
65-
return $this->_authorization->isAllowed('Magento_Reports::accounts');
66-
break;
67-
case 'orders':
68-
return $this->_authorization->isAllowed('Magento_Reports::customers_orders');
69-
break;
70-
case 'totals':
71-
return $this->_authorization->isAllowed('Magento_Reports::totals');
72-
break;
73-
default:
74-
return $this->_authorization->isAllowed('Magento_Reports::customers');
75-
break;
76-
}
68+
return match ($this->getRequest()->getActionName()) {
69+
'exportAccountsCsv', 'exportAccountsExcel', 'accounts' =>
70+
$this->_authorization->isAllowed('Magento_Reports::accounts'),
71+
'exportOrdersCsv', 'exportOrdersExcel','orders' =>
72+
$this->_authorization->isAllowed('Magento_Reports::customers_orders'),
73+
'exportTotalsCsv', 'exportTotalsExcel', 'totals' =>
74+
$this->_authorization->isAllowed('Magento_Reports::totals'),
75+
default =>
76+
$this->_authorization->isAllowed('Magento_Reports::customers'),
77+
};
7778
}
7879
}

app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportSoldCsv.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
declare(strict_types=1);
8+
79
namespace Magento\Reports\Controller\Adminhtml\Report\Product;
810

911
use Magento\Backend\Block\Widget\Grid\ExportInterface;
12+
use Magento\Framework\App\Action\HttpPostActionInterface;
1013
use Magento\Framework\App\ResponseInterface;
1114
use Magento\Framework\App\Filesystem\DirectoryList;
15+
use Magento\Reports\Controller\Adminhtml\Report\Product;
1216

13-
class ExportSoldCsv extends \Magento\Reports\Controller\Adminhtml\Report\Product
17+
class ExportSoldCsv extends Product implements HttpPostActionInterface
1418
{
1519
/**
1620
* Authorization level of a basic admin session
1721
*
1822
* @see _isAllowed()
1923
*/
20-
const ADMIN_RESOURCE = 'Magento_Reports::report_products';
24+
public const ADMIN_RESOURCE = 'Magento_Reports::sold';
2125

2226
/**
2327
* Export Sold Products report to CSV format action

app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportSoldExcel.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
declare(strict_types=1);
8+
79
namespace Magento\Reports\Controller\Adminhtml\Report\Product;
810

911
use Magento\Backend\Block\Widget\Grid\ExportInterface;
12+
use Magento\Framework\App\Action\HttpPostActionInterface;
1013
use Magento\Framework\App\ResponseInterface;
1114
use Magento\Framework\App\Filesystem\DirectoryList;
15+
use Magento\Reports\Controller\Adminhtml\Report\Product;
1216

13-
class ExportSoldExcel extends \Magento\Reports\Controller\Adminhtml\Report\Product
17+
class ExportSoldExcel extends Product implements HttpPostActionInterface
1418
{
1519
/**
1620
* Authorization level of a basic admin session
1721
*
1822
* @see _isAllowed()
1923
*/
20-
const ADMIN_RESOURCE = 'Magento_Reports::report_products';
24+
public const ADMIN_RESOURCE = 'Magento_Reports::sold';
2125

2226
/**
2327
* Export Sold Products report to XML format action

app/code/Magento/Search/Controller/Adminhtml/Term.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,42 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Search\Controller\Adminhtml;
79

810
use Magento\Backend\App\Action;
11+
use Magento\Backend\Model\View\Result\Page;
912
use Magento\Framework\Controller\ResultFactory;
1013

1114
abstract class Term extends Action
1215
{
1316
/**
14-
* Authorization level of a basic admin session
17+
* Add search term breadcrumbs
1518
*
16-
* @see _isAllowed()
17-
*/
18-
const ADMIN_RESOURCE = 'Magento_Search::search';
19-
20-
/**
21-
* @return \Magento\Backend\Model\View\Result\Page
19+
* @return Page
2220
*/
2321
protected function createPage()
2422
{
25-
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
23+
/** @var Page $resultPage */
2624
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
2725
$resultPage->setActiveMenu('Magento_Search::search_terms')
2826
->addBreadcrumb(__('Search'), __('Search'));
2927
return $resultPage;
3028
}
29+
30+
/**
31+
* Determine if action is allowed for reports
32+
*
33+
* @return bool
34+
*/
35+
protected function _isAllowed(): bool
36+
{
37+
return match ($this->getRequest()->getActionName()) {
38+
'exportSearchCsv', 'exportSearchExcel' =>
39+
$this->_authorization->isAllowed('Magento_Reports::report_search'),
40+
default =>
41+
$this->_authorization->isAllowed('Magento_Search::search'),
42+
};
43+
}
3144
}

0 commit comments

Comments
 (0)