99
1010use Magento \Checkout \Model \Cart \RequestQuantityProcessor ;
1111use Magento \Checkout \Model \Sidebar ;
12+ use Magento \Framework \App \Action \Action ;
13+ use Magento \Framework \App \Action \Context ;
1214use Magento \Framework \App \Action \HttpPostActionInterface ;
1315use Magento \Framework \App \ObjectManager ;
14- use Magento \Framework \App \RequestInterface ;
1516use Magento \Framework \App \Response \Http ;
16- use Magento \Framework \App \ResponseInterface ;
1717use Magento \Framework \Exception \LocalizedException ;
1818use Magento \Framework \Json \Helper \Data ;
1919use Psr \Log \LoggerInterface ;
2020
21- class UpdateItemQty implements HttpPostActionInterface
21+ class UpdateItemQty extends Action implements HttpPostActionInterface
2222{
2323 /**
2424 * @var Sidebar
@@ -41,37 +41,24 @@ class UpdateItemQty implements HttpPostActionInterface
4141 private $ quantityProcessor ;
4242
4343 /**
44- * @var RequestInterface
45- */
46- private $ request ;
47-
48- /**
49- * @var ResponseInterface
50- */
51- private $ response ;
52-
53- /**
44+ * @param Context $context
5445 * @param Sidebar $sidebar
5546 * @param LoggerInterface $logger
5647 * @param Data $jsonHelper
57- * @param RequestInterface $request
58- * @param ResponseInterface $response
5948 * @param RequestQuantityProcessor|null $quantityProcessor
6049 * @codeCoverageIgnore
6150 */
6251 public function __construct (
52+ Context $ context ,
6353 Sidebar $ sidebar ,
6454 LoggerInterface $ logger ,
6555 Data $ jsonHelper ,
66- RequestInterface $ request ,
67- ResponseInterface $ response ,
6856 ?RequestQuantityProcessor $ quantityProcessor = null
6957 ) {
7058 $ this ->sidebar = $ sidebar ;
7159 $ this ->logger = $ logger ;
7260 $ this ->jsonHelper = $ jsonHelper ;
73- $ this ->request = $ request ;
74- $ this ->response = $ response ;
61+ parent ::__construct ($ context );
7562 $ this ->quantityProcessor = $ quantityProcessor
7663 ?? ObjectManager::getInstance ()->get (RequestQuantityProcessor::class);
7764 }
@@ -83,8 +70,8 @@ public function __construct(
8370 */
8471 public function execute ()
8572 {
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 ' );
8875
8976 if ($ itemQty <= 0 ) {
9077 return $ this ->jsonResponse (__ ('A non-numeric value found ' ));
@@ -111,7 +98,7 @@ public function execute()
11198 */
11299 protected function jsonResponse ($ error = '' )
113100 {
114- return $ this ->response ->representJson (
101+ return $ this ->getResponse () ->representJson (
115102 $ this ->jsonHelper ->jsonEncode ($ this ->sidebar ->getResponseData ($ error ))
116103 );
117104 }
0 commit comments