public function getResult() { if(!defined('JSON_UNESCAPED_SLASHES')) { return str_replace('\/', '/', parent::getResult()); } else { return parent::getResult(); } }
/** * {@inheritdoc} */ public function getResult() { $result = $this->getRoot(); if ($result) { $meta = null; $included = null; $links = null; // strip out included part, since it does not belong to the primary resource data if (isset($result['included'])) { $included = $result['included']; unset($result['included']); } if (isset($result['meta'])) { $meta = $result['meta']; unset($result['meta']); } if (isset($result['links'])) { $links = $result['links']; unset($result['links']); } // filter out duplicate primary resource objects that are in `included` $included = array_udiff((array) $included, $result, function ($a, $b) { return strcmp($a['type'] . $a['id'], $b['type'] . $b['id']); }); $root = array(); if ($this->showVersionInfo) { $root['jsonapi'] = array('version' => '1.0'); } if ($meta) { $root['meta'] = $meta; } if ($links) { $root['links'] = $links; } $root['data'] = array_values($result); if ($included) { $root['included'] = array_values($included); } $this->setRoot($root); } return parent::getResult(); }
/** * {@inheritdoc} */ public function getResult() { if (false === $this->isJsonApiDocument) { return parent::getResult(); } $root = $this->getRoot(); // TODO: Error handling if (isset($root['data']) && array_key_exists('errors', $root['data'])) { return parent::getResult(); } if ($root) { $data = array(); $meta = array(); $included = array(); $links = array(); if (isset($root['data'])) { $data = $root['data']; } if (isset($root['included'])) { $included = $root['included']; } if (isset($root['meta'])) { $meta = $root['meta']; } if (isset($root['links'])) { $links = $root['links']; } // filter out duplicate primary resource objects that are in `included` $included = array_udiff((array) $included, isset($data['type']) ? [$data] : $data, function ($a, $b) { return strcmp($a['type'] . $a['id'], $b['type'] . $b['id']); }); // start building new root array $root = array(); if ($this->showVersionInfo) { $root['jsonapi'] = array('version' => '1.0'); } if ($meta) { $root['meta'] = $meta; } if ($links) { $root['links'] = $links; } $root['data'] = $data; if ($included) { $root['included'] = array_values($included); } $this->setRoot($root); } return parent::getResult(); }
public function getResult() { return str_replace('\\/', '/', parent::getResult()); }