16
16
class Editor extends Textarea
17
17
{
18
18
/**
19
+ * @var \Magento\Framework\Serialize\Serializer\Json
20
+ */
21
+ private $ serializer ;
22
+
23
+ /**
24
+ * Editor constructor.
19
25
* @param Factory $factoryElement
20
26
* @param CollectionFactory $factoryCollection
21
27
* @param Escaper $escaper
22
28
* @param array $data
29
+ * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
30
+ * @throws \RuntimeException
23
31
*/
24
32
public function __construct (
25
33
Factory $ factoryElement ,
26
34
CollectionFactory $ factoryCollection ,
27
35
Escaper $ escaper ,
28
- $ data = []
36
+ $ data = [],
37
+ \Magento \Framework \Serialize \Serializer \Json $ serializer = null
29
38
) {
30
39
parent ::__construct ($ factoryElement , $ factoryCollection , $ escaper , $ data );
31
40
@@ -36,6 +45,9 @@ public function __construct(
36
45
$ this ->setType ('textarea ' );
37
46
$ this ->setExtType ('textarea ' );
38
47
}
48
+
49
+ $ this ->serializer = $ serializer ?: \Magento \Framework \App \ObjectManager::getInstance ()
50
+ ->get (\Magento \Framework \Serialize \Serializer \Json::class);
39
51
}
40
52
41
53
/**
@@ -55,6 +67,7 @@ protected function getButtonTranslations()
55
67
/**
56
68
* @return string
57
69
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
70
+ * @throws \InvalidArgumentException
58
71
*/
59
72
public function getElementHtml ()
60
73
{
@@ -141,7 +154,7 @@ public function getElementHtml()
141
154
' = new tinyMceWysiwygSetup(" ' .
142
155
$ this ->getHtmlId () .
143
156
'", ' .
144
- \Zend_Json:: encode (
157
+ $ this -> serializer -> serialize (
145
158
$ this ->getConfig ()
146
159
) .
147
160
'); ' .
@@ -180,7 +193,7 @@ public function getElementHtml()
180
193
//<![CDATA[
181
194
require(["jquery", "mage/translate", "mage/adminhtml/wysiwyg/widget"], function(jQuery){
182
195
(function($) {
183
- $.mage.translate.add( ' . \Zend_Json:: encode ($ this ->getButtonTranslations ()) . ')
196
+ $.mage.translate.add( ' . $ this -> serializer -> serialize ($ this ->getButtonTranslations ()) . ')
184
197
})(jQuery);
185
198
});
186
199
//]]>
@@ -425,7 +438,7 @@ public function getConfig($key = null)
425
438
* Translate string using defined helper
426
439
*
427
440
* @param string $string String to be translated
428
- * @return \Magento\Framework\Phrase
441
+ * @return string
429
442
*/
430
443
public function translate ($ string )
431
444
{
0 commit comments