CoreFiles by mySites.guru
HtmlRenderer.php80 lines, 1,890 bytes, from Joomla_4.0.0-beta4-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta3
md5
28fcc1791eca991460b1626c612499a3
sha1
d32cd8d811cf9ec079b9658c3150828e7d886441
sha256
aca87a77417d9b67d0c99522e89472da4e20e0a49d29bc98652e7c080692af0a
<?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.