Skip to content

Commit 9263b1d

Browse files
committed
#9236: allow for setData to take in an object of type DataObject
1 parent 41a4cf6 commit 9263b1d

File tree

1 file changed

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

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ public function __construct(
5252
* @param boolean $cycleCheck Optional; whether or not to check for object recursion; off by default
5353
* @param array $options Additional options used during encoding
5454
* @return $this
55+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5556
*/
5657
public function setData($data, $cycleCheck = false, $options = [])
5758
{
59+
if ($data instanceof \Magento\Framework\DataObject) {
60+
$data = $data->toArray();
61+
}
5862
$this->json = $this->serializer->serialize($data);
5963
return $this;
6064
}

0 commit comments

Comments
 (0)