5
5
*/
6
6
namespace Magento \Checkout \Controller \Sidebar ;
7
7
8
- use Magento \Checkout \Controller \Cart ;
9
- use Magento \Checkout \Model \Cart as CustomerCart ;
10
- use Magento \Checkout \Model \Session ;
11
8
use Magento \Checkout \Model \Sidebar ;
9
+ use Magento \Framework \App \Action \Action ;
12
10
use Magento \Framework \App \Action \Context ;
13
- use Magento \Framework \App \Config \ScopeConfigInterface ;
14
11
use Magento \Framework \App \Response \Http ;
15
- use Magento \Framework \Controller \Result \RedirectFactory ;
16
- use Magento \Framework \Data \Form \FormKey \Validator ;
17
12
use Magento \Framework \Exception \LocalizedException ;
18
- use Magento \Store \Model \StoreManagerInterface ;
13
+ use Magento \Framework \Json \Helper \Data ;
14
+ use Psr \Log \LoggerInterface ;
19
15
20
- class UpdateItemQty extends Cart
16
+ class UpdateItemQty extends Action
21
17
{
22
18
/**
23
19
* @var Sidebar
24
20
*/
25
21
protected $ sidebar ;
26
22
23
+ /**
24
+ * @var LoggerInterface
25
+ */
26
+ protected $ logger ;
27
+
28
+ /**
29
+ * @var Data
30
+ */
31
+ protected $ jsonHelper ;
32
+
27
33
/**
28
34
* @param Context $context
29
- * @param ScopeConfigInterface $scopeConfig
30
- * @param Session $checkoutSession
31
- * @param StoreManagerInterface $storeManager
32
- * @param Validator $formKeyValidator
33
- * @param CustomerCart $cart
34
- * @param RedirectFactory $resultRedirectFactory
35
35
* @param Sidebar $sidebar
36
+ * @param LoggerInterface $logger
37
+ * @param Data $jsonHelper
36
38
*/
37
39
public function __construct (
38
40
Context $ context ,
39
- ScopeConfigInterface $ scopeConfig ,
40
- Session $ checkoutSession ,
41
- StoreManagerInterface $ storeManager ,
42
- Validator $ formKeyValidator ,
43
- CustomerCart $ cart ,
44
- RedirectFactory $ resultRedirectFactory ,
45
- Sidebar $ sidebar
41
+ Sidebar $ sidebar ,
42
+ LoggerInterface $ logger ,
43
+ Data $ jsonHelper
46
44
) {
47
45
$ this ->sidebar = $ sidebar ;
48
- parent ::__construct (
49
- $ context ,
50
- $ scopeConfig ,
51
- $ checkoutSession ,
52
- $ storeManager ,
53
- $ formKeyValidator ,
54
- $ cart ,
55
- $ resultRedirectFactory
56
- );
46
+ $ this ->logger = $ logger ;
47
+ $ this ->jsonHelper = $ jsonHelper ;
48
+ parent ::__construct ($ context );
57
49
}
58
50
59
51
/**
@@ -71,7 +63,7 @@ public function execute()
71
63
} catch (LocalizedException $ e ) {
72
64
return $ this ->jsonResponse ($ e ->getMessage ());
73
65
} catch (\Exception $ e ) {
74
- $ this ->_objectManager -> get ( ' Psr\Log\LoggerInterface ' ) ->critical ($ e );
66
+ $ this ->logger ->critical ($ e );
75
67
return $ this ->jsonResponse ($ e ->getMessage ());
76
68
}
77
69
}
@@ -82,11 +74,10 @@ public function execute()
82
74
* @param string $error
83
75
* @return Http
84
76
*/
85
- public function jsonResponse ($ error = '' )
77
+ protected function jsonResponse ($ error = '' )
86
78
{
87
79
return $ this ->getResponse ()->representJson (
88
- $ this ->_objectManager ->get ('Magento\Framework\Json\Helper\Data ' )
89
- ->jsonEncode ($ this ->sidebar ->getResponseData ($ error ))
80
+ $ this ->jsonHelper ->jsonEncode ($ this ->sidebar ->getResponseData ($ error ))
90
81
);
91
82
}
92
83
}
0 commit comments