9
9
10
10
use Magento \Checkout \Model \Cart \RequestQuantityProcessor ;
11
11
use Magento \Checkout \Model \Sidebar ;
12
+ use Magento \Framework \App \Action \Action ;
13
+ use Magento \Framework \App \Action \Context ;
12
14
use Magento \Framework \App \Action \HttpPostActionInterface ;
13
15
use Magento \Framework \App \ObjectManager ;
14
- use Magento \Framework \App \RequestInterface ;
15
16
use Magento \Framework \App \Response \Http ;
16
- use Magento \Framework \App \ResponseInterface ;
17
17
use Magento \Framework \Exception \LocalizedException ;
18
18
use Magento \Framework \Json \Helper \Data ;
19
19
use Psr \Log \LoggerInterface ;
20
20
21
- class UpdateItemQty implements HttpPostActionInterface
21
+ class UpdateItemQty extends Action implements HttpPostActionInterface
22
22
{
23
23
/**
24
24
* @var Sidebar
@@ -41,37 +41,24 @@ class UpdateItemQty implements HttpPostActionInterface
41
41
private $ quantityProcessor ;
42
42
43
43
/**
44
- * @var RequestInterface
45
- */
46
- private $ request ;
47
-
48
- /**
49
- * @var ResponseInterface
50
- */
51
- private $ response ;
52
-
53
- /**
44
+ * @param Context $context
54
45
* @param Sidebar $sidebar
55
46
* @param LoggerInterface $logger
56
47
* @param Data $jsonHelper
57
- * @param RequestInterface $request
58
- * @param ResponseInterface $response
59
48
* @param RequestQuantityProcessor|null $quantityProcessor
60
49
* @codeCoverageIgnore
61
50
*/
62
51
public function __construct (
52
+ Context $ context ,
63
53
Sidebar $ sidebar ,
64
54
LoggerInterface $ logger ,
65
55
Data $ jsonHelper ,
66
- RequestInterface $ request ,
67
- ResponseInterface $ response ,
68
56
?RequestQuantityProcessor $ quantityProcessor = null
69
57
) {
70
58
$ this ->sidebar = $ sidebar ;
71
59
$ this ->logger = $ logger ;
72
60
$ this ->jsonHelper = $ jsonHelper ;
73
- $ this ->request = $ request ;
74
- $ this ->response = $ response ;
61
+ parent ::__construct ($ context );
75
62
$ this ->quantityProcessor = $ quantityProcessor
76
63
?? ObjectManager::getInstance ()->get (RequestQuantityProcessor::class);
77
64
}
@@ -83,8 +70,8 @@ public function __construct(
83
70
*/
84
71
public function execute ()
85
72
{
86
- $ itemId = (int )$ this ->request ->getParam ('item_id ' );
87
- $ itemQty = (int )$ this ->request ->getParam ('item_qty ' );
73
+ $ itemId = (int )$ this ->getRequest () ->getParam ('item_id ' );
74
+ $ itemQty = (int )$ this ->getRequest () ->getParam ('item_qty ' );
88
75
89
76
if ($ itemQty <= 0 ) {
90
77
return $ this ->jsonResponse (__ ('A non-numeric value found ' ));
@@ -111,7 +98,7 @@ public function execute()
111
98
*/
112
99
protected function jsonResponse ($ error = '' )
113
100
{
114
- return $ this ->response ->representJson (
101
+ return $ this ->getResponse () ->representJson (
115
102
$ this ->jsonHelper ->jsonEncode ($ this ->sidebar ->getResponseData ($ error ))
116
103
);
117
104
}
0 commit comments