Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explace the direct usage of Zend_Json with a call to the Json Help class #9344

Merged
merged 2 commits into from
Jun 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,25 @@ class Layout extends \Magento\Backend\Block\Template implements \Magento\Framewo
*/
protected $_productType;

/**
* @var \Magento\Framework\Serialize\Serializer\Json
*/
private $serializer;

/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Catalog\Model\Product\Type $productType
* @param array $data
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Catalog\Model\Product\Type $productType,
array $data = []
array $data = [],
\Magento\Framework\Serialize\Serializer\Json $serializer = null
) {
$this->_productType = $productType;
$this->serializer = $serializer;
parent::__construct($context, $data);
}

Expand Down Expand Up @@ -335,17 +343,26 @@ public function getPageGroups()
$pageGroups = [];
if ($widgetInstance->getPageGroups()) {
foreach ($widgetInstance->getPageGroups() as $pageGroup) {
$pageGroups[] = [
'page_id' => $pageGroup['page_id'],
'group' => $pageGroup['page_group'],
'block' => $pageGroup['block_reference'],
'for_value' => $pageGroup['page_for'],
'layout_handle' => $pageGroup['layout_handle'],
$pageGroup['page_group'] . '_entities' => $pageGroup['entities'],
'template' => $pageGroup['page_template'],
];
$pageGroups[] = $this->serializer->serialize($this->getPageGroup($pageGroup));
}
}
return $pageGroups;
}

/**
* @param array $pageGroup
* @return array
*/
private function getPageGroup(array $pageGroup)
{
return [
'page_id' => $pageGroup['page_id'],
'group' => $pageGroup['page_group'],
'block' => $pageGroup['block_reference'],
'for_value' => $pageGroup['page_for'],
'layout_handle' => $pageGroup['layout_handle'],
$pageGroup['page_group'] . '_entities' => $pageGroup['entities'],
'template' => $pageGroup['page_template'],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ window.WidgetInstance = WidgetInstance;

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