@@ -45,7 +45,6 @@ public function __construct(
45
45
$ this ->setType ('textarea ' );
46
46
$ this ->setExtType ('textarea ' );
47
47
}
48
-
49
48
$ this ->serializer = $ serializer ?: \Magento \Framework \App \ObjectManager::getInstance ()
50
49
->get (\Magento \Framework \Serialize \Serializer \Json::class);
51
50
}
@@ -64,10 +63,24 @@ protected function getButtonTranslations()
64
63
return $ buttonTranslations ;
65
64
}
66
65
66
+ /**
67
+ * @return bool|string
68
+ * @throws \InvalidArgumentException
69
+ */
70
+ private function getJsonConfig ()
71
+ {
72
+ if (is_object ($ this ->getConfig ()) && method_exists ($ this ->getConfig (), 'toJson ' )) {
73
+ return $ this ->getConfig ()->toJson ();
74
+ } else {
75
+ return $ this ->serializer ->serialize (
76
+ $ this ->getConfig ()
77
+ );
78
+ }
79
+ }
80
+
67
81
/**
68
82
* @return string
69
83
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
70
- * @throws \InvalidArgumentException
71
84
*/
72
85
public function getElementHtml ()
73
86
{
@@ -145,7 +158,7 @@ public function getElementHtml()
145
158
], function(jQuery){ ' .
146
159
"\n" .
147
160
' (function($) {$.mage.translate.add( ' .
148
- \Zend_Json:: encode (
161
+ $ this -> serializer -> serialize (
149
162
$ this ->getButtonTranslations ()
150
163
) .
151
164
')})(jQuery); ' .
@@ -154,9 +167,7 @@ public function getElementHtml()
154
167
' = new tinyMceWysiwygSetup(" ' .
155
168
$ this ->getHtmlId () .
156
169
'", ' .
157
- $ this ->serializer ->serialize (
158
- $ this ->getConfig ()
159
- ) .
170
+ $ this ->getJsonConfig () .
160
171
'); ' .
161
172
$ forceLoad .
162
173
'
@@ -438,7 +449,7 @@ public function getConfig($key = null)
438
449
* Translate string using defined helper
439
450
*
440
451
* @param string $string String to be translated
441
- * @return string
452
+ * @return \Magento\Framework\Phrase
442
453
*/
443
454
public function translate ($ string )
444
455
{
0 commit comments