Skip to content

Commit b379aea

Browse files
committed
Replace Zend_Json in the editor form element
1 parent 62c566d commit b379aea

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Editablemultiselect extends \Magento\Framework\Data\Form\Element\Multisele
2929
* @param Escaper $escaper
3030
* @param array $data
3131
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
32+
* @throws \RuntimeException
3233
*/
3334
public function __construct(
3435
Factory $factoryElement,
@@ -53,6 +54,7 @@ public function __construct(
5354
* Retrieve HTML markup of the element
5455
*
5556
* @return string
57+
* @throws \InvalidArgumentException
5658
*/
5759
public function getElementHtml()
5860
{

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,25 @@
1616
class Editor extends Textarea
1717
{
1818
/**
19+
* @var \Magento\Framework\Serialize\Serializer\Json
20+
*/
21+
private $serializer;
22+
23+
/**
24+
* Editor constructor.
1925
* @param Factory $factoryElement
2026
* @param CollectionFactory $factoryCollection
2127
* @param Escaper $escaper
2228
* @param array $data
29+
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
30+
* @throws \RuntimeException
2331
*/
2432
public function __construct(
2533
Factory $factoryElement,
2634
CollectionFactory $factoryCollection,
2735
Escaper $escaper,
28-
$data = []
36+
$data = [],
37+
\Magento\Framework\Serialize\Serializer\Json $serializer = null
2938
) {
3039
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
3140

@@ -36,6 +45,9 @@ public function __construct(
3645
$this->setType('textarea');
3746
$this->setExtType('textarea');
3847
}
48+
49+
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
50+
->get(\Magento\Framework\Serialize\Serializer\Json::class);
3951
}
4052

4153
/**
@@ -55,6 +67,7 @@ protected function getButtonTranslations()
5567
/**
5668
* @return string
5769
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
70+
* @throws \InvalidArgumentException
5871
*/
5972
public function getElementHtml()
6073
{
@@ -141,7 +154,7 @@ public function getElementHtml()
141154
' = new tinyMceWysiwygSetup("' .
142155
$this->getHtmlId() .
143156
'", ' .
144-
\Zend_Json::encode(
157+
$this->serializer->serialize(
145158
$this->getConfig()
146159
) .
147160
');' .
@@ -180,7 +193,7 @@ public function getElementHtml()
180193
//<![CDATA[
181194
require(["jquery", "mage/translate", "mage/adminhtml/wysiwyg/widget"], function(jQuery){
182195
(function($) {
183-
$.mage.translate.add(' . \Zend_Json::encode($this->getButtonTranslations()) . ')
196+
$.mage.translate.add(' . $this->serializer->serialize($this->getButtonTranslations()) . ')
184197
})(jQuery);
185198
});
186199
//]]>
@@ -425,7 +438,7 @@ public function getConfig($key = null)
425438
* Translate string using defined helper
426439
*
427440
* @param string $string String to be translated
428-
* @return \Magento\Framework\Phrase
441+
* @return string
429442
*/
430443
public function translate($string)
431444
{

0 commit comments

Comments
 (0)