Skip to content

Commit 67fbe61

Browse files
author
Oleksii Korshenko
committed
MAGETWO-71062: Remove zend json from json controller #10342
- Reverted Pull Request #10342 from dmanners/magento2:remove-zend-json-from-json-controller - Merged commits: 1. baeb58c 2. db6f353 3. 4f78388 4. 7e46cea 5. ff0581b 6. 41e118b
1 parent c4d8578 commit 67fbe61

File tree

3 files changed

+9
-52
lines changed

3 files changed

+9
-52
lines changed

app/code/Magento/Tax/Controller/Adminhtml/Rate/AjaxLoad.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ class AjaxLoad extends \Magento\Tax\Controller\Adminhtml\Rate
1414
/**
1515
* Json needed for the Ajax Edit Form
1616
*
17-
* @return \Magento\Framework\Controller\Result\Json
18-
* @throws \InvalidArgumentException
17+
* @return void
1918
*/
2019
public function execute()
2120
{

app/code/Magento/Tax/Controller/Adminhtml/Rate/AjaxSave.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class AjaxSave extends \Magento\Tax\Controller\Adminhtml\Rate
1414
* Save Tax Rate via AJAX
1515
*
1616
* @return \Magento\Framework\Controller\Result\Json
17-
* @throws \InvalidArgumentException
1817
*/
1918
public function execute()
2019
{

lib/internal/Magento/Framework/Controller/Result/Json.php

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -29,65 +29,24 @@ class Json extends AbstractResult
2929
protected $json;
3030

3131
/**
32-
* @var \Magento\Framework\Serialize\Serializer\Json
32+
* @param \Magento\Framework\Translate\InlineInterface $translateInline
3333
*/
34-
private $serializer;
35-
36-
/**
37-
* @param InlineInterface $translateInline
38-
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
39-
* @throws \RuntimeException
40-
*/
41-
public function __construct(
42-
InlineInterface $translateInline,
43-
\Magento\Framework\Serialize\Serializer\Json $serializer = null
44-
) {
34+
public function __construct(InlineInterface $translateInline)
35+
{
4536
$this->translateInline = $translateInline;
46-
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
47-
->get(\Magento\Framework\Serialize\Serializer\Json::class);
4837
}
4938

5039
/**
5140
* Set json data
5241
*
53-
* @param array|string|\Magento\Framework\DataObject $data
54-
* @param bool $cycleCheck
55-
* @param array $options
56-
* @return Json
57-
* @throws \InvalidArgumentException
58-
* @throws \Magento\Framework\Exception\LocalizedException
59-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
60-
* @deprecated
61-
* @see Json::setArrayData
62-
* @see Json::setJsonData
63-
*/
64-
public function setData($data, $cycleCheck = false, $options = [])
65-
{
66-
if ($data instanceof \Magento\Framework\DataObject) {
67-
return $this->setArrayData($data->toArray());
68-
}
69-
70-
if (is_array($data)) {
71-
return $this->setArrayData($data);
72-
}
73-
74-
if (is_string($data)) {
75-
return $this->setJsonData($data);
76-
}
77-
78-
throw new \Magento\Framework\Exception\LocalizedException(
79-
new \Magento\Framework\Phrase('Invalid argument type')
80-
);
81-
}
82-
83-
/**
84-
* @param array $data
42+
* @param mixed $data
43+
* @param boolean $cycleCheck Optional; whether or not to check for object recursion; off by default
44+
* @param array $options Additional options used during encoding
8545
* @return $this
86-
* @throws \InvalidArgumentException
8746
*/
88-
public function setArrayData(array $data)
47+
public function setData($data, $cycleCheck = false, $options = [])
8948
{
90-
$this->setJsonData($this->serializer->serialize($data));
49+
$this->json = \Zend_Json::encode($data, $cycleCheck, $options);
9150
return $this;
9251
}
9352

0 commit comments

Comments
 (0)