3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+
6
7
namespace Magento \Checkout \Block \Cart ;
7
8
9
+ use Magento \Checkout \Model \CompositeConfigProvider ;
10
+ use Magento \Checkout \Block \Checkout \LayoutProcessorInterface ;
11
+ use Magento \Framework \Serialize \Serializer \Json ;
12
+ use Magento \Framework \Serialize \Serializer \JsonHexTag ;
13
+ use Magento \Framework \View \Element \Template \Context ;
14
+ use Magento \Customer \Model \Session as CustomerSession ;
15
+ use Magento \Checkout \Model \Session as CheckoutSession ;
16
+ use Magento \Framework \App \ObjectManager ;
17
+
8
18
/**
19
+ * Cart Shipping Block
20
+ *
9
21
* @api
10
22
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
11
23
*/
12
24
class Shipping extends \Magento \Checkout \Block \Cart \AbstractCart
13
25
{
14
26
/**
15
- * @var \Magento\Checkout\Model\ CompositeConfigProvider
27
+ * @var CompositeConfigProvider
16
28
*/
17
29
protected $ configProvider ;
18
30
19
31
/**
20
- * @var array|\Magento\Checkout\Block\Checkout\ LayoutProcessorInterface[]
32
+ * @var array|LayoutProcessorInterface[]
21
33
*/
22
34
protected $ layoutProcessors ;
23
35
24
36
/**
25
- * @var \Magento\Framework\Serialize\Serializer\ Json
37
+ * @var Json
26
38
*/
27
39
private $ serializer ;
28
40
29
41
/**
30
- * @param \Magento\Framework\View\Element\Template\Context $context
31
- * @param \Magento\Customer\Model\Session $customerSession
32
- * @param \Magento\Checkout\Model\Session $checkoutSession
33
- * @param \Magento\Checkout\Model\CompositeConfigProvider $configProvider
42
+ * @var JsonHexTag
43
+ */
44
+ private $ jsonHexTagSerializer ;
45
+
46
+ /**
47
+ * @param Context $context
48
+ * @param CustomerSession $customerSession
49
+ * @param CheckoutSession $checkoutSession
50
+ * @param CompositeConfigProvider $configProvider
34
51
* @param array $layoutProcessors
35
52
* @param array $data
36
- * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
53
+ * @param Json|null $serializer
54
+ * @param JsonHexTag|null $jsonHexTagSerializer
37
55
* @throws \RuntimeException
38
56
*/
39
57
public function __construct (
40
- \ Magento \ Framework \ View \ Element \ Template \ Context $ context ,
41
- \ Magento \ Customer \ Model \ Session $ customerSession ,
42
- \ Magento \ Checkout \ Model \ Session $ checkoutSession ,
43
- \ Magento \ Checkout \ Model \ CompositeConfigProvider $ configProvider ,
58
+ Context $ context ,
59
+ CustomerSession $ customerSession ,
60
+ CheckoutSession $ checkoutSession ,
61
+ CompositeConfigProvider $ configProvider ,
44
62
array $ layoutProcessors = [],
45
63
array $ data = [],
46
- \Magento \Framework \Serialize \Serializer \Json $ serializer = null
64
+ Json $ serializer = null ,
65
+ JsonHexTag $ jsonHexTagSerializer = null
47
66
) {
48
67
$ this ->configProvider = $ configProvider ;
49
68
$ this ->layoutProcessors = $ layoutProcessors ;
50
69
parent ::__construct ($ context , $ customerSession , $ checkoutSession , $ data );
51
70
$ this ->_isScopePrivate = true ;
52
- $ this ->serializer = $ serializer ?: \ Magento \ Framework \ App \ ObjectManager::getInstance ()
53
- ->get (\ Magento \ Framework \ Serialize \ Serializer \Json ::class);
71
+ $ this ->serializer = $ serializer ?: ObjectManager::getInstance ()-> get (Json::class);
72
+ $ this -> jsonHexTagSerializer = $ jsonHexTagSerializer ?: ObjectManager:: getInstance () ->get (JsonHexTag ::class);
54
73
}
55
74
56
75
/**
@@ -75,7 +94,7 @@ public function getJsLayout()
75
94
$ this ->jsLayout = $ processor ->process ($ this ->jsLayout );
76
95
}
77
96
78
- return json_encode ($ this ->jsLayout , JSON_HEX_TAG );
97
+ return $ this -> jsonHexTagSerializer -> serialize ($ this ->jsLayout );
79
98
}
80
99
81
100
/**
@@ -90,11 +109,13 @@ public function getBaseUrl()
90
109
}
91
110
92
111
/**
112
+ * Get Serialized Checkout Config
113
+ *
93
114
* @return bool|string
94
115
* @since 100.2.0
95
116
*/
96
117
public function getSerializedCheckoutConfig ()
97
118
{
98
- return json_encode ($ this ->getCheckoutConfig (), JSON_HEX_TAG );
119
+ return $ this -> jsonHexTagSerializer -> serialize ($ this ->getCheckoutConfig ());
99
120
}
100
121
}
0 commit comments