diff --git a/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php b/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php index 9e43f1d11bed0..60d374fbf26ca 100644 --- a/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php +++ b/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php @@ -53,9 +53,15 @@ class Save extends AbstractAction /** * @var DecoderInterface + * @deprecated */ protected $jsonDecoder; + /** + * @var \Magento\Framework\Serialize\Serializer\Json + */ + private $serializer; + /** * @param Context $context * @param UiComponentFactory $factory @@ -64,6 +70,8 @@ class Save extends AbstractAction * @param BookmarkInterfaceFactory $bookmarkFactory * @param UserContextInterface $userContext * @param DecoderInterface $jsonDecoder + * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer + * @throws \RuntimeException */ public function __construct( Context $context, @@ -72,7 +80,8 @@ public function __construct( BookmarkManagementInterface $bookmarkManagement, BookmarkInterfaceFactory $bookmarkFactory, UserContextInterface $userContext, - DecoderInterface $jsonDecoder + DecoderInterface $jsonDecoder, + \Magento\Framework\Serialize\Serializer\Json $serializer = null ) { parent::__construct($context, $factory); $this->bookmarkRepository = $bookmarkRepository; @@ -80,12 +89,16 @@ public function __construct( $this->bookmarkFactory = $bookmarkFactory; $this->userContext = $userContext; $this->jsonDecoder = $jsonDecoder; + $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\Framework\Serialize\Serializer\Json::class); } /** * Action for AJAX request * * @return void + * @throws \InvalidArgumentException + * @throws \LogicException */ public function execute() { @@ -94,7 +107,7 @@ public function execute() if (!$jsonData) { throw new \InvalidArgumentException('Invalid parameter "data"'); } - $data = $this->jsonDecoder->decode($jsonData); + $data = $this->serializer->unserialize($jsonData); $action = key($data); switch ($action) { case self::ACTIVE_IDENTIFIER: diff --git a/app/code/Magento/Ui/Model/Bookmark.php b/app/code/Magento/Ui/Model/Bookmark.php index 88da0e0b79c77..b404e8d3b475f 100644 --- a/app/code/Magento/Ui/Model/Bookmark.php +++ b/app/code/Magento/Ui/Model/Bookmark.php @@ -23,9 +23,15 @@ class Bookmark extends AbstractExtensibleModel implements BookmarkInterface { /** * @var DecoderInterface + * @deprecated */ protected $jsonDecoder; + /** + * @var \Magento\Framework\Serialize\Serializer\Json + */ + private $serializer; + /** * @param Context $context * @param Registry $registry @@ -35,6 +41,8 @@ class Bookmark extends AbstractExtensibleModel implements BookmarkInterface * @param Collection $resourceCollection * @param DecoderInterface $jsonDecoder * @param array $data + * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer + * @throws \RuntimeException */ public function __construct( Context $context, @@ -44,9 +52,12 @@ public function __construct( ResourceBookmark $resource, Collection $resourceCollection, DecoderInterface $jsonDecoder, - array $data = [] + array $data = [], + \Magento\Framework\Serialize\Serializer\Json $serializer = null ) { $this->jsonDecoder = $jsonDecoder; + $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\Framework\Serialize\Serializer\Json::class); parent::__construct( $context, $registry, @@ -127,7 +138,7 @@ public function getConfig() { $config = $this->getData(self::CONFIG); if ($config) { - return $this->jsonDecoder->decode($config); + return $this->serializer->unserialize($config); } return []; }