Skip to content

Commit 7bb5972

Browse files
ENGCOM-1173: Remove json helper data usage in AdminNotification #14438
- Merge Pull Request #14438 from dmanners/magento2:remove-json-helper-data - Merged commits: 1. cdca73b 2. 6561541
2 parents 63e5713 + 6561541 commit 7bb5972

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

app/code/Magento/AdminNotification/Block/System/Messages.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,34 @@ class Messages extends \Magento\Backend\Block\Template
1616

1717
/**
1818
* @var \Magento\Framework\Json\Helper\Data
19+
* @deprecated
1920
*/
2021
protected $jsonHelper;
2122

23+
/**
24+
* @var \Magento\Framework\Serialize\Serializer\Json
25+
*/
26+
private $serializer;
27+
2228
/**
2329
* @param \Magento\Backend\Block\Template\Context $context
2430
* @param \Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized $messages
2531
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
2632
* @param array $data
33+
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
2734
*/
2835
public function __construct(
2936
\Magento\Backend\Block\Template\Context $context,
3037
\Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized $messages,
3138
\Magento\Framework\Json\Helper\Data $jsonHelper,
32-
array $data = []
39+
array $data = [],
40+
\Magento\Framework\Serialize\Serializer\Json $serializer = null
3341
) {
3442
$this->jsonHelper = $jsonHelper;
3543
parent::__construct($context, $data);
3644
$this->_messages = $messages;
45+
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
46+
->get(\Magento\Framework\Serialize\Serializer\Json::class);
3747
}
3848

3949
/**
@@ -117,7 +127,7 @@ protected function _getMessagesUrl()
117127
*/
118128
public function getSystemMessageDialogJson()
119129
{
120-
return $this->jsonHelper->jsonEncode(
130+
return $this->serializer->serialize(
121131
[
122132
'systemMessageDialog' => [
123133
'buttons' => [],

app/code/Magento/AdminNotification/Controller/Adminhtml/System/Message/ListAction.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77
namespace Magento\AdminNotification\Controller\Adminhtml\System\Message;
88

9+
use Magento\Framework\Controller\ResultFactory;
10+
911
class ListAction extends \Magento\Backend\App\AbstractAction
1012
{
1113
/**
@@ -15,6 +17,7 @@ class ListAction extends \Magento\Backend\App\AbstractAction
1517

1618
/**
1719
* @var \Magento\Framework\Json\Helper\Data
20+
* @deprecated
1821
*/
1922
protected $jsonHelper;
2023

@@ -41,7 +44,7 @@ public function __construct(
4144
}
4245

4346
/**
44-
* @return void
47+
* @return \Magento\Framework\Controller\Result\Json
4548
*/
4649
public function execute()
4750
{
@@ -63,6 +66,9 @@ public function execute()
6366
. 'Please refresh the web page to clear the notice alert.',
6467
];
6568
}
66-
$this->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
69+
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
70+
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
71+
$resultJson->setData($result);
72+
return $resultJson;
6773
}
6874
}

0 commit comments

Comments
 (0)