@@ -67,15 +67,24 @@ class Form extends \Magento\Framework\View\Element\Template
6767 protected $ jsLayout ;
6868
6969 /**
70+ * @var \Magento\Framework\Serialize\Serializer\Json
71+ */
72+ private $ serializer ;
73+
74+ /**
75+ * Form constructor.
76+ *
7077 * @param \Magento\Framework\View\Element\Template\Context $context
7178 * @param \Magento\Framework\Url\EncoderInterface $urlEncoder
7279 * @param \Magento\Review\Helper\Data $reviewData
7380 * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
7481 * @param \Magento\Review\Model\RatingFactory $ratingFactory
7582 * @param \Magento\Framework\Message\ManagerInterface $messageManager
7683 * @param \Magento\Framework\App\Http\Context $httpContext
77- * @param \Magento\Customer\Model\ Url $customerUrl
84+ * @param Url $customerUrl
7885 * @param array $data
86+ * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
87+ * @throws \RuntimeException
7988 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
8089 */
8190 public function __construct (
@@ -87,7 +96,8 @@ public function __construct(
8796 \Magento \Framework \Message \ManagerInterface $ messageManager ,
8897 \Magento \Framework \App \Http \Context $ httpContext ,
8998 \Magento \Customer \Model \Url $ customerUrl ,
90- array $ data = []
99+ array $ data = [],
100+ \Magento \Framework \Serialize \Serializer \Json $ serializer = null
91101 ) {
92102 $ this ->urlEncoder = $ urlEncoder ;
93103 $ this ->_reviewData = $ reviewData ;
@@ -98,6 +108,8 @@ public function __construct(
98108 $ this ->customerUrl = $ customerUrl ;
99109 parent ::__construct ($ context , $ data );
100110 $ this ->jsLayout = isset ($ data ['jsLayout ' ]) ? $ data ['jsLayout ' ] : [];
111+ $ this ->serializer = $ serializer ?: \Magento \Framework \App \ObjectManager::getInstance ()
112+ ->get (\Magento \Framework \Serialize \Serializer \Json::class);
101113 }
102114
103115 /**
@@ -133,13 +145,13 @@ protected function _construct()
133145 */
134146 public function getJsLayout ()
135147 {
136- return \Zend_Json:: encode ($ this ->jsLayout );
148+ return $ this -> serializer -> serialize ($ this ->jsLayout );
137149 }
138150
139151 /**
140152 * Get product info
141153 *
142- * @return Product
154+ * @return \Magento\Catalog\Api\Data\ProductInterface
143155 * @throws \Magento\Framework\Exception\NoSuchEntityException
144156 */
145157 public function getProductInfo ()
@@ -171,6 +183,7 @@ public function getAction()
171183 * Get collection of ratings
172184 *
173185 * @return RatingCollection
186+ * @throws \Magento\Framework\Exception\LocalizedException
174187 */
175188 public function getRatings ()
176189 {
0 commit comments