Back to ErrorDocument class

Method render

public string
render
(mixed $cache = false, mixed $params = array())
Render the document
Parameters
  • bool $cache If true, cache the output
  • array $params Associative array of attributes
Returns
  • string The rendered data
Since
  • 1.7.0
Class: ErrorDocument
Project: Joomla

Method render - Source code

/**
 * Render the document
 *
 * @param   boolean  $cache   If true, cache the output
 * @param   array    $params  Associative array of attributes
 *
 * @return  string   The rendered data
 *
 * @since   1.7.0
 */
public function render($cache = false, $params = array())
{
    // If no error object is set return null
    if (!isset($this->_error)) {
        return;
    }
    // Set the status header
    $status = $this->_error->getCode();
    if ($status < 400 || $status > 599) {
        $status = 500;
    }
    $errorReporting = CmsFactory::getApplication()->get('error_reporting');
    if ($errorReporting === "development" || $errorReporting === "maximum") {
        $status .= ' ' . str_replace("\n", ' ', $this->_error->getMessage());
    }
    CmsFactory::getApplication()->setHeader('status', $status);
    // Set variables
    $this->debug = $params['debug'] ?? false;
    $this->error = $this->_error;
    $params['file'] = 'error.php';
    return parent::render($cache, $params);
}