File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
lib/internal/Magento/Framework/Controller/Result Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -29,11 +29,22 @@ class Json extends AbstractResult
2929 protected $ json ;
3030
3131 /**
32- * @param \Magento\Framework\Translate\InlineInterface $translateInline
32+ * @var \Magento\Framework\Serialize\Serializer\Json
3333 */
34- public function __construct (InlineInterface $ translateInline )
35- {
34+ private $ serializer ;
35+
36+ /**
37+ * @param InlineInterface $translateInline
38+ * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
39+ * @throws \RuntimeException
40+ */
41+ public function __construct (
42+ InlineInterface $ translateInline ,
43+ \Magento \Framework \Serialize \Serializer \Json $ serializer = null
44+ ) {
3645 $ this ->translateInline = $ translateInline ;
46+ $ this ->serializer = $ serializer ?: \Magento \Framework \App \ObjectManager::getInstance ()
47+ ->get (\Magento \Framework \Serialize \Serializer \Json::class);
3748 }
3849
3950 /**
@@ -43,10 +54,11 @@ public function __construct(InlineInterface $translateInline)
4354 * @param boolean $cycleCheck Optional; whether or not to check for object recursion; off by default
4455 * @param array $options Additional options used during encoding
4556 * @return $this
57+ * @throws \InvalidArgumentException
4658 */
4759 public function setData ($ data , $ cycleCheck = false , $ options = [])
4860 {
49- $ this ->json = \Zend_Json:: encode ($ data, $ cycleCheck , $ options );
61+ $ this ->json = $ this -> serializer -> serialize ($ data );
5062 return $ this ;
5163 }
5264
You can’t perform that action at this time.
0 commit comments