Back to JsonapiDocument class

Method render

public string
render
(mixed $cache = false, mixed $params = array())
Outputs the document.
Parameters
  • bool $cache If true, cache the output.
  • array $params Associative array of attributes.
Returns
  • string The rendered data.
Since
  • 4.0.0

Method render - Source code

/**
 * Outputs the document.
 *
 * @param   boolean  $cache   If true, cache the output.
 * @param   array    $params  Associative array of attributes.
 *
 * @return  string  The rendered data.
 *
 * @since  4.0.0
 */
public function render($cache = false, $params = array())
{
    $app = Factory::getApplication();
    if ($mdate = $this->getModifiedDate()) {
        $app->modifiedDate = $mdate;
    }
    $app->mimeType = $this->_mime;
    $app->charSet = $this->_charset;
    return json_encode($this->document);
}