Skip to content

Commit 24be963

Browse files
MAGETWO-86645: Remove zend json from json result controller #13137
2 parents afea5f0 + 5d16369 commit 24be963

File tree

1 file changed

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

1 file changed

+16
-3
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,21 @@ class Json extends AbstractResult
2828
*/
2929
protected $json;
3030

31+
/**
32+
* @var \Magento\Framework\Serialize\Serializer\Json
33+
*/
34+
private $serializer;
35+
3136
/**
3237
* @param \Magento\Framework\Translate\InlineInterface $translateInline
3338
*/
34-
public function __construct(InlineInterface $translateInline)
35-
{
39+
public function __construct(
40+
InlineInterface $translateInline,
41+
\Magento\Framework\Serialize\Serializer\Json $serializer = null
42+
) {
3643
$this->translateInline = $translateInline;
44+
$this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
45+
->get(\Magento\Framework\Serialize\Serializer\Json::class);
3746
}
3847

3948
/**
@@ -43,10 +52,14 @@ public function __construct(InlineInterface $translateInline)
4352
* @param boolean $cycleCheck Optional; whether or not to check for object recursion; off by default
4453
* @param array $options Additional options used during encoding
4554
* @return $this
55+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4656
*/
4757
public function setData($data, $cycleCheck = false, $options = [])
4858
{
49-
$this->json = \Zend_Json::encode($data, $cycleCheck, $options);
59+
if ($data instanceof \Magento\Framework\DataObject) {
60+
$data = $data->toArray();
61+
}
62+
$this->json = $this->serializer->serialize($data);
5063
return $this;
5164
}
5265

0 commit comments

Comments
 (0)