Skip to content

Commit 6479c6a

Browse files
committed
MAGETWO-69369: Explace the direct usage of Zend_Json with a call to the Json Help class #9344
- Merge Pull Request #9344 from dmanners/magento2:remove-zend-json-from-widget
2 parents 34b0747 + b78fab0 commit 6479c6a

File tree

2 files changed

+28
-11
lines changed
  • app/code/Magento/Widget

2 files changed

+28
-11
lines changed

app/code/Magento/Widget/Block/Adminhtml/Widget/Instance/Edit/Tab/Main/Layout.php

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,25 @@ class Layout extends \Magento\Backend\Block\Template implements \Magento\Framewo
3232
*/
3333
protected $_productType;
3434

35+
/**
36+
* @var \Magento\Framework\Serialize\Serializer\Json
37+
*/
38+
private $serializer;
39+
3540
/**
3641
* @param \Magento\Backend\Block\Template\Context $context
3742
* @param \Magento\Catalog\Model\Product\Type $productType
3843
* @param array $data
44+
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
3945
*/
4046
public function __construct(
4147
\Magento\Backend\Block\Template\Context $context,
4248
\Magento\Catalog\Model\Product\Type $productType,
43-
array $data = []
49+
array $data = [],
50+
\Magento\Framework\Serialize\Serializer\Json $serializer = null
4451
) {
4552
$this->_productType = $productType;
53+
$this->serializer = $serializer;
4654
parent::__construct($context, $data);
4755
}
4856

@@ -335,17 +343,26 @@ public function getPageGroups()
335343
$pageGroups = [];
336344
if ($widgetInstance->getPageGroups()) {
337345
foreach ($widgetInstance->getPageGroups() as $pageGroup) {
338-
$pageGroups[] = [
339-
'page_id' => $pageGroup['page_id'],
340-
'group' => $pageGroup['page_group'],
341-
'block' => $pageGroup['block_reference'],
342-
'for_value' => $pageGroup['page_for'],
343-
'layout_handle' => $pageGroup['layout_handle'],
344-
$pageGroup['page_group'] . '_entities' => $pageGroup['entities'],
345-
'template' => $pageGroup['page_template'],
346-
];
346+
$pageGroups[] = $this->serializer->serialize($this->getPageGroup($pageGroup));
347347
}
348348
}
349349
return $pageGroups;
350350
}
351+
352+
/**
353+
* @param array $pageGroup
354+
* @return array
355+
*/
356+
private function getPageGroup(array $pageGroup)
357+
{
358+
return [
359+
'page_id' => $pageGroup['page_id'],
360+
'group' => $pageGroup['page_group'],
361+
'block' => $pageGroup['block_reference'],
362+
'for_value' => $pageGroup['page_for'],
363+
'layout_handle' => $pageGroup['layout_handle'],
364+
$pageGroup['page_group'] . '_entities' => $pageGroup['entities'],
365+
'template' => $pageGroup['page_template'],
366+
];
367+
}
351368
}

app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ window.WidgetInstance = WidgetInstance;
487487

488488
jQuery(function(){
489489
<?php foreach ($block->getPageGroups() as $pageGroup): ?>
490-
WidgetInstance.addPageGroup(<?php /* @noEscape */ echo Zend_Json::encode($pageGroup) ?>);
490+
WidgetInstance.addPageGroup(<?php /* @noEscape */ echo $pageGroup ?>);
491491
<?php endforeach; ?>
492492
Event.observe(document, 'product:changed', function(event){
493493
WidgetInstance.checkProduct(event);

0 commit comments

Comments
 (0)