- md5
- 28fcc1791eca991460b1626c612499a3
- sha1
- d32cd8d811cf9ec079b9658c3150828e7d886441
- sha256
- aca87a77417d9b67d0c99522e89472da4e20e0a49d29bc98652e7c080692af0a
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\CMS\Error\Renderer;
\defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Error\AbstractRenderer;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
/**
* HTML error page renderer
*
* @since 4.0
* @todo Change this renderer to use JDocumentHtml instead of JDocumentError, the latter is only used for B/C at this time
*/
class HtmlRenderer extends AbstractRenderer
{
/**
* The format (type) of the error page
*
* @var string
* @since 4.0
*/
protected $type = 'error';
/**
* Render the error page for the given object
*
* @param \Throwable $error The error object to be rendered
*
* @return string
*
* @since 4.0
*/
public function render(\Throwable $error): string
{
$app = Factory::getApplication();
// Get the current template from the application
$template = $app->getTemplate(true);
// Push the error object into the document
$this->getDocument()->setError($error);
// Add registry file for the template asset
$wa = $this->getDocument()->getWebAssetManager()->getRegistry();
$wa->addTemplateRegistryFile($template->template, $app->getClientId());
if (!empty($template->parent))
{
$wa->addTemplateRegistryFile($template->parent, $app->getClientId());
}
if (ob_get_contents())
{
ob_end_clean();
}
$this->getDocument()->setTitle(Text::_('Error') . ': ' . $error->getCode());
return $this->getDocument()->render(
false,
[
'template' => $template->template,
'directory' => JPATH_THEMES,
'debug' => JDEBUG,
'csp_nonce' => $app->get('csp_nonce'),
'templateInherits' => $template->parent
]
);
}
}
The same content is in 2 releases, Joomla 4.0.0-beta4 to 4.0.0-beta5. See them all, or every version of this file.