Skip to content

Commit

Permalink
Merge pull request #1389 from magento-engcom/develop-prs
Browse files Browse the repository at this point in the history
[EngCom] Public Pull Requests
 - MAGETWO-71392: Remove decoder interface usage #10453
  • Loading branch information
ishakhsuvarov authored Aug 8, 2017
2 parents 0548157 + a0b21d3 commit 354fc11
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
17 changes: 15 additions & 2 deletions app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -72,20 +80,25 @@ 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;
$this->bookmarkManagement = $bookmarkManagement;
$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()
{
Expand All @@ -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:
Expand Down
15 changes: 13 additions & 2 deletions app/code/Magento/Ui/Model/Bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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 [];
}
Expand Down

0 comments on commit 354fc11

Please sign in to comment.