Skip to content

Commit abb39b4

Browse files
committed
Fix issue with config not serializing as it is a multi level object
1 parent b379aea commit abb39b4

File tree

1 file changed

+18
-7
lines changed
  • lib/internal/Magento/Framework/Data/Form/Element

1 file changed

+18
-7
lines changed

lib/internal/Magento/Framework/Data/Form/Element/Editor.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public function __construct(
4545
$this->setType('textarea');
4646
$this->setExtType('textarea');
4747
}
48-
4948
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
5049
->get(\Magento\Framework\Serialize\Serializer\Json::class);
5150
}
@@ -64,10 +63,24 @@ protected function getButtonTranslations()
6463
return $buttonTranslations;
6564
}
6665

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+
6781
/**
6882
* @return string
6983
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
70-
* @throws \InvalidArgumentException
7184
*/
7285
public function getElementHtml()
7386
{
@@ -145,7 +158,7 @@ public function getElementHtml()
145158
], function(jQuery){' .
146159
"\n" .
147160
' (function($) {$.mage.translate.add(' .
148-
\Zend_Json::encode(
161+
$this->serializer->serialize(
149162
$this->getButtonTranslations()
150163
) .
151164
')})(jQuery);' .
@@ -154,9 +167,7 @@ public function getElementHtml()
154167
' = new tinyMceWysiwygSetup("' .
155168
$this->getHtmlId() .
156169
'", ' .
157-
$this->serializer->serialize(
158-
$this->getConfig()
159-
) .
170+
$this->getJsonConfig() .
160171
');' .
161172
$forceLoad .
162173
'
@@ -438,7 +449,7 @@ public function getConfig($key = null)
438449
* Translate string using defined helper
439450
*
440451
* @param string $string String to be translated
441-
* @return string
452+
* @return \Magento\Framework\Phrase
442453
*/
443454
public function translate($string)
444455
{

0 commit comments

Comments
 (0)