File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
lib/internal/Magento/Framework/Controller/Result Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -28,12 +28,21 @@ class Json extends AbstractResult
28
28
*/
29
29
protected $ json ;
30
30
31
+ /**
32
+ * @var \Magento\Framework\Serialize\Serializer\Json
33
+ */
34
+ private $ serializer ;
35
+
31
36
/**
32
37
* @param \Magento\Framework\Translate\InlineInterface $translateInline
33
38
*/
34
- public function __construct (InlineInterface $ translateInline )
35
- {
39
+ public function __construct (
40
+ InlineInterface $ translateInline ,
41
+ \Magento \Framework \Serialize \Serializer \Json $ serializer = null
42
+ ) {
36
43
$ this ->translateInline = $ translateInline ;
44
+ $ this ->serializer = $ serializer ?: \Magento \Framework \App \ObjectManager::getInstance ()
45
+ ->get (\Magento \Framework \Serialize \Serializer \Json::class);
37
46
}
38
47
39
48
/**
@@ -43,10 +52,14 @@ public function __construct(InlineInterface $translateInline)
43
52
* @param boolean $cycleCheck Optional; whether or not to check for object recursion; off by default
44
53
* @param array $options Additional options used during encoding
45
54
* @return $this
55
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
46
56
*/
47
57
public function setData ($ data , $ cycleCheck = false , $ options = [])
48
58
{
49
- $ this ->json = \Zend_Json::encode ($ data , $ cycleCheck , $ options );
59
+ if ($ data instanceof \Magento \Framework \DataObject) {
60
+ $ data = $ data ->toArray ();
61
+ }
62
+ $ this ->json = $ this ->serializer ->serialize ($ data );
50
63
return $ this ;
51
64
}
52
65
You can’t perform that action at this time.
0 commit comments