Skip to content

Commit baeb58c

Browse files
committed
Remove the usage of Zend_Json from the controller results json file.
- use the \Magento\Framework\Serialize\Serializer\Json instead of Zend_Json
1 parent a7f2db6 commit baeb58c

File tree

1 file changed

+16
-4
lines changed
  • lib/internal/Magento/Framework/Controller/Result

1 file changed

+16
-4
lines changed

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,22 @@ class Json extends AbstractResult
2929
protected $json;
3030

3131
/**
32-
* @param \Magento\Framework\Translate\InlineInterface $translateInline
32+
* @var \Magento\Framework\Serialize\Serializer\Json
3333
*/
34-
public function __construct(InlineInterface $translateInline)
35-
{
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+
) {
3645
$this->translateInline = $translateInline;
46+
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
47+
->get(\Magento\Framework\Serialize\Serializer\Json::class);
3748
}
3849

3950
/**
@@ -43,10 +54,11 @@ public function __construct(InlineInterface $translateInline)
4354
* @param boolean $cycleCheck Optional; whether or not to check for object recursion; off by default
4455
* @param array $options Additional options used during encoding
4556
* @return $this
57+
* @throws \InvalidArgumentException
4658
*/
4759
public function setData($data, $cycleCheck = false, $options = [])
4860
{
49-
$this->json = \Zend_Json::encode($data, $cycleCheck, $options);
61+
$this->json = $this->serializer->serialize($data);
5062
return $this;
5163
}
5264

0 commit comments

Comments
 (0)