Skip to content

Commit a7daed4

Browse files
committed
AC-12448: Enhancement on Admin cart functionality
1 parent 4ff8b0f commit a7daed4

File tree

4 files changed

+49
-4
lines changed
  • app/code/Magento/Customer/Controller/Adminhtml
  • dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/undeclared_dependency

4 files changed

+49
-4
lines changed

app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Quote\Model\Quote\Item;
1313
use Magento\Quote\Model\QuoteFactory;
1414
use Magento\Quote\Model\ResourceModel\QuoteItemRetriever;
15+
use Magento\Framework\AuthorizationInterface;
1516

1617
/**
1718
* Catalog composite product configuration controller
@@ -60,21 +61,30 @@ abstract class Cart extends \Magento\Backend\App\Action
6061
* @var QuoteItemRetriever
6162
*/
6263
private $quoteItemRetriever;
64+
65+
/**
66+
* @var AuthorizationInterface
67+
*/
68+
protected $_authorization;
69+
6370
/**
6471
* @param Action\Context $context
6572
* @param CartRepositoryInterface $quoteRepository
6673
* @param QuoteFactory $quoteFactory
6774
* @param QuoteItemRetriever $quoteItemRetriever
75+
* @param AuthorizationInterface $authorization
6876
*/
6977
public function __construct(
7078
Action\Context $context,
7179
CartRepositoryInterface $quoteRepository,
7280
QuoteFactory $quoteFactory,
73-
QuoteItemRetriever $quoteItemRetriever
81+
QuoteItemRetriever $quoteItemRetriever,
82+
AuthorizationInterface $authorization
7483
) {
7584
$this->quoteRepository = $quoteRepository;
7685
$this->quoteFactory = $quoteFactory;
7786
$this->quoteItemRetriever = $quoteItemRetriever;
87+
$this->_authorization = $authorization;
7888
parent::__construct($context);
7989
}
8090

@@ -112,4 +122,13 @@ protected function _initData()
112122

113123
return $this;
114124
}
125+
126+
/**
127+
* @inheritdoc
128+
*/
129+
protected function _isAllowed()
130+
{
131+
return $this->_authorization->isAllowed(self::ADMIN_RESOURCE)
132+
&& $this->_authorization->isAllowed('Magento_Cart::cart');
133+
}
115134
}

app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php

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

810
use Magento\Backend\App\Action\Context;
@@ -43,6 +45,7 @@
4345
*
4446
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
4547
* @deprecated 101.0.0
48+
* @see no alternatives
4649
*/
4750
class Cart extends BaseAction implements HttpGetActionInterface, HttpPostActionInterface
4851
{
@@ -55,6 +58,13 @@ class Cart extends BaseAction implements HttpGetActionInterface, HttpPostActionI
5558
*/
5659
private $storeManager;
5760

61+
/**
62+
* Authorization level of a basic admin cart
63+
*
64+
* @see _isAllowed()
65+
*/
66+
public const ADMIN_RESOURCE = 'Magento_Cart::cart';
67+
5868
/**
5969
* Constructor
6070
*

app/code/Magento/Customer/Controller/Adminhtml/Index/Carts.php

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

8-
class Carts extends \Magento\Customer\Controller\Adminhtml\Index
10+
use Magento\Customer\Controller\Adminhtml\Index as BaseAction;
11+
use Magento\Framework\App\Action\HttpGetActionInterface;
12+
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
13+
14+
class Carts extends BaseAction implements HttpGetActionInterface, HttpPostActionInterface
915
{
16+
/**
17+
* Authorization level of a basic admin cart
18+
*
19+
* @see _isAllowed()
20+
*/
21+
public const ADMIN_RESOURCE = 'Magento_Cart::cart';
22+
1023
/**
1124
* Get shopping carts from all websites for specified client
1225
*
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<?php
22
/**
3-
* Black list for the @see \Magento\Test\Integrity\DependencyTest::testUndeclared()
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
5+
*
6+
* Black list for the @see \Magento\Test\Integrity\DependencyTest::testUndeclared()
77
*/
88
return [
99
'app/code/Magento/Paypal/Model/AbstractConfig.php' => ['Magento\Cart'],
10+
'app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php' => ['Magento\Cart'],
11+
'app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php' => ['Magento\Cart'],
12+
'app/code/Magento/Customer/Controller/Adminhtml/Index/Carts.php' => ['Magento\Cart'],
1013
];

0 commit comments

Comments
 (0)