public \Joomla\CMS\Document\RendererInterface
createRenderer
(\Joomla\CMS\Document\Document $document, string $type, string $docType = '')
/**
* Creates a new renderer object.
*
* @param Document $document The Document instance to attach to the renderer
* @param string $type The renderer type to instantiate
* @param string $docType The document type the renderer is part of
*
* @return RendererInterface
*
* @since 4.0.0
*/
public function createRenderer(Document $document, string $type, string $docType = '') : RendererInterface
{
$docType = $docType ? ucfirst($docType) : ucfirst($document->getType());
// Determine the path and class
$class = __NAMESPACE__ . '\\Renderer\\' . $docType . '\\' . ucfirst($type) . 'Renderer';
if (!class_exists($class)) {
$class = 'JDocumentRenderer' . $docType . ucfirst($type);
}
if (!class_exists($class)) {
// "Legacy" class name structure
$class = '\\JDocumentRenderer' . $type;
if (!class_exists($class)) {
throw new \RuntimeException(sprintf('Unable to load renderer class %s', $type), 500);
}
}
return new $class($document);
}