Skip to content

Commit 354fc11

Browse files
Merge pull request #1389 from magento-engcom/develop-prs
[EngCom] Public Pull Requests - MAGETWO-71392: Remove decoder interface usage #10453
2 parents 0548157 + a0b21d3 commit 354fc11

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,15 @@ class Save extends AbstractAction
5353

5454
/**
5555
* @var DecoderInterface
56+
* @deprecated
5657
*/
5758
protected $jsonDecoder;
5859

60+
/**
61+
* @var \Magento\Framework\Serialize\Serializer\Json
62+
*/
63+
private $serializer;
64+
5965
/**
6066
* @param Context $context
6167
* @param UiComponentFactory $factory
@@ -64,6 +70,8 @@ class Save extends AbstractAction
6470
* @param BookmarkInterfaceFactory $bookmarkFactory
6571
* @param UserContextInterface $userContext
6672
* @param DecoderInterface $jsonDecoder
73+
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
74+
* @throws \RuntimeException
6775
*/
6876
public function __construct(
6977
Context $context,
@@ -72,20 +80,25 @@ public function __construct(
7280
BookmarkManagementInterface $bookmarkManagement,
7381
BookmarkInterfaceFactory $bookmarkFactory,
7482
UserContextInterface $userContext,
75-
DecoderInterface $jsonDecoder
83+
DecoderInterface $jsonDecoder,
84+
\Magento\Framework\Serialize\Serializer\Json $serializer = null
7685
) {
7786
parent::__construct($context, $factory);
7887
$this->bookmarkRepository = $bookmarkRepository;
7988
$this->bookmarkManagement = $bookmarkManagement;
8089
$this->bookmarkFactory = $bookmarkFactory;
8190
$this->userContext = $userContext;
8291
$this->jsonDecoder = $jsonDecoder;
92+
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
93+
->get(\Magento\Framework\Serialize\Serializer\Json::class);
8394
}
8495

8596
/**
8697
* Action for AJAX request
8798
*
8899
* @return void
100+
* @throws \InvalidArgumentException
101+
* @throws \LogicException
89102
*/
90103
public function execute()
91104
{
@@ -94,7 +107,7 @@ public function execute()
94107
if (!$jsonData) {
95108
throw new \InvalidArgumentException('Invalid parameter "data"');
96109
}
97-
$data = $this->jsonDecoder->decode($jsonData);
110+
$data = $this->serializer->unserialize($jsonData);
98111
$action = key($data);
99112
switch ($action) {
100113
case self::ACTIVE_IDENTIFIER:

app/code/Magento/Ui/Model/Bookmark.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@ class Bookmark extends AbstractExtensibleModel implements BookmarkInterface
2323
{
2424
/**
2525
* @var DecoderInterface
26+
* @deprecated
2627
*/
2728
protected $jsonDecoder;
2829

30+
/**
31+
* @var \Magento\Framework\Serialize\Serializer\Json
32+
*/
33+
private $serializer;
34+
2935
/**
3036
* @param Context $context
3137
* @param Registry $registry
@@ -35,6 +41,8 @@ class Bookmark extends AbstractExtensibleModel implements BookmarkInterface
3541
* @param Collection $resourceCollection
3642
* @param DecoderInterface $jsonDecoder
3743
* @param array $data
44+
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
45+
* @throws \RuntimeException
3846
*/
3947
public function __construct(
4048
Context $context,
@@ -44,9 +52,12 @@ public function __construct(
4452
ResourceBookmark $resource,
4553
Collection $resourceCollection,
4654
DecoderInterface $jsonDecoder,
47-
array $data = []
55+
array $data = [],
56+
\Magento\Framework\Serialize\Serializer\Json $serializer = null
4857
) {
4958
$this->jsonDecoder = $jsonDecoder;
59+
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
60+
->get(\Magento\Framework\Serialize\Serializer\Json::class);
5061
parent::__construct(
5162
$context,
5263
$registry,
@@ -127,7 +138,7 @@ public function getConfig()
127138
{
128139
$config = $this->getData(self::CONFIG);
129140
if ($config) {
130-
return $this->jsonDecoder->decode($config);
141+
return $this->serializer->unserialize($config);
131142
}
132143
return [];
133144
}

0 commit comments

Comments
 (0)