@@ -67,15 +67,24 @@ class Form extends \Magento\Framework\View\Element\Template
67
67
protected $ jsLayout ;
68
68
69
69
/**
70
+ * @var \Magento\Framework\Serialize\Serializer\Json
71
+ */
72
+ private $ serializer ;
73
+
74
+ /**
75
+ * Form constructor.
76
+ *
70
77
* @param \Magento\Framework\View\Element\Template\Context $context
71
78
* @param \Magento\Framework\Url\EncoderInterface $urlEncoder
72
79
* @param \Magento\Review\Helper\Data $reviewData
73
80
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
74
81
* @param \Magento\Review\Model\RatingFactory $ratingFactory
75
82
* @param \Magento\Framework\Message\ManagerInterface $messageManager
76
83
* @param \Magento\Framework\App\Http\Context $httpContext
77
- * @param \Magento\Customer\Model\ Url $customerUrl
84
+ * @param Url $customerUrl
78
85
* @param array $data
86
+ * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
87
+ * @throws \RuntimeException
79
88
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
80
89
*/
81
90
public function __construct (
@@ -87,7 +96,8 @@ public function __construct(
87
96
\Magento \Framework \Message \ManagerInterface $ messageManager ,
88
97
\Magento \Framework \App \Http \Context $ httpContext ,
89
98
\Magento \Customer \Model \Url $ customerUrl ,
90
- array $ data = []
99
+ array $ data = [],
100
+ \Magento \Framework \Serialize \Serializer \Json $ serializer = null
91
101
) {
92
102
$ this ->urlEncoder = $ urlEncoder ;
93
103
$ this ->_reviewData = $ reviewData ;
@@ -98,6 +108,8 @@ public function __construct(
98
108
$ this ->customerUrl = $ customerUrl ;
99
109
parent ::__construct ($ context , $ data );
100
110
$ this ->jsLayout = isset ($ data ['jsLayout ' ]) ? $ data ['jsLayout ' ] : [];
111
+ $ this ->serializer = $ serializer ?: \Magento \Framework \App \ObjectManager::getInstance ()
112
+ ->get (\Magento \Framework \Serialize \Serializer \Json::class);
101
113
}
102
114
103
115
/**
@@ -133,13 +145,13 @@ protected function _construct()
133
145
*/
134
146
public function getJsLayout ()
135
147
{
136
- return \Zend_Json:: encode ($ this ->jsLayout );
148
+ return $ this -> serializer -> serialize ($ this ->jsLayout );
137
149
}
138
150
139
151
/**
140
152
* Get product info
141
153
*
142
- * @return Product
154
+ * @return \Magento\Catalog\Api\Data\ProductInterface
143
155
* @throws \Magento\Framework\Exception\NoSuchEntityException
144
156
*/
145
157
public function getProductInfo ()
@@ -171,6 +183,7 @@ public function getAction()
171
183
* Get collection of ratings
172
184
*
173
185
* @return RatingCollection
186
+ * @throws \Magento\Framework\Exception\LocalizedException
174
187
*/
175
188
public function getRatings ()
176
189
{
0 commit comments