Skip to content

Commit 075eba8

Browse files
committed
Replace the usage of Magento\Framework\Json\DecoderInterface in the bookmark save controller
- deprecate $jsonDecoder, - inject the new \Magento\Framework\Serialize\Serializer\Json, - replace usage of $jsonDecoder with $serializer
1 parent e9fa41e commit 075eba8

File tree

1 file changed

+13
-2
lines changed
  • app/code/Magento/Ui/Controller/Adminhtml/Bookmark

1 file changed

+13
-2
lines changed

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

Lines changed: 13 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
@@ -72,20 +78,25 @@ public function __construct(
7278
BookmarkManagementInterface $bookmarkManagement,
7379
BookmarkInterfaceFactory $bookmarkFactory,
7480
UserContextInterface $userContext,
75-
DecoderInterface $jsonDecoder
81+
DecoderInterface $jsonDecoder,
82+
\Magento\Framework\Serialize\Serializer\Json $serializer = null
7683
) {
7784
parent::__construct($context, $factory);
7885
$this->bookmarkRepository = $bookmarkRepository;
7986
$this->bookmarkManagement = $bookmarkManagement;
8087
$this->bookmarkFactory = $bookmarkFactory;
8188
$this->userContext = $userContext;
8289
$this->jsonDecoder = $jsonDecoder;
90+
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
91+
->get(\Magento\Framework\Serialize\Serializer\Json::class);
8392
}
8493

8594
/**
8695
* Action for AJAX request
8796
*
8897
* @return void
98+
* @throws \InvalidArgumentException
99+
* @throws \LogicException
89100
*/
90101
public function execute()
91102
{
@@ -94,7 +105,7 @@ public function execute()
94105
if (!$jsonData) {
95106
throw new \InvalidArgumentException('Invalid parameter "data"');
96107
}
97-
$data = $this->jsonDecoder->decode($jsonData);
108+
$data = $this->serializer->unserialize($jsonData);
98109
$action = key($data);
99110
switch ($action) {
100111
case self::ACTIVE_IDENTIFIER:

0 commit comments

Comments
 (0)