@@ -29,65 +29,24 @@ class Json extends AbstractResult
29
29
protected $ json ;
30
30
31
31
/**
32
- * @var \Magento\Framework\Serialize\Serializer\Json
32
+ * @param \Magento\Framework\Translate\InlineInterface $translateInline
33
33
*/
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
- ) {
34
+ public function __construct (InlineInterface $ translateInline )
35
+ {
45
36
$ this ->translateInline = $ translateInline ;
46
- $ this ->serializer = $ serializer ?: \Magento \Framework \App \ObjectManager::getInstance ()
47
- ->get (\Magento \Framework \Serialize \Serializer \Json::class);
48
37
}
49
38
50
39
/**
51
40
* Set json data
52
41
*
53
- * @param array|string|\Magento\Framework\DataObject $data
54
- * @param bool $cycleCheck
55
- * @param array $options
56
- * @return Json
57
- * @throws \InvalidArgumentException
58
- * @throws \Magento\Framework\Exception\LocalizedException
59
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
60
- * @deprecated
61
- * @see Json::setArrayData
62
- * @see Json::setJsonData
63
- */
64
- public function setData ($ data , $ cycleCheck = false , $ options = [])
65
- {
66
- if ($ data instanceof \Magento \Framework \DataObject) {
67
- return $ this ->setArrayData ($ data ->toArray ());
68
- }
69
-
70
- if (is_array ($ data )) {
71
- return $ this ->setArrayData ($ data );
72
- }
73
-
74
- if (is_string ($ data )) {
75
- return $ this ->setJsonData ($ data );
76
- }
77
-
78
- throw new \Magento \Framework \Exception \LocalizedException (
79
- new \Magento \Framework \Phrase ('Invalid argument type ' )
80
- );
81
- }
82
-
83
- /**
84
- * @param array $data
42
+ * @param mixed $data
43
+ * @param boolean $cycleCheck Optional; whether or not to check for object recursion; off by default
44
+ * @param array $options Additional options used during encoding
85
45
* @return $this
86
- * @throws \InvalidArgumentException
87
46
*/
88
- public function setArrayData ( array $ data )
47
+ public function setData ( $ data, $ cycleCheck = false , $ options = [] )
89
48
{
90
- $ this ->setJsonData ( $ this -> serializer -> serialize ( $ data) );
49
+ $ this ->json = \Zend_Json:: encode ( $ data, $ cycleCheck , $ options );
91
50
return $ this ;
92
51
}
93
52
0 commit comments