Commit ee1488a6 by Carsten Brandt

Merge pull request #2086 from jom/apidoc_extendable

Simplify apidoc's RenderController::findRenderer to allow for custom renderers via ext
parents 13f0bd66 d7b20977
...@@ -103,15 +103,11 @@ class RenderController extends Controller ...@@ -103,15 +103,11 @@ class RenderController extends Controller
*/ */
protected function findRenderer() protected function findRenderer()
{ {
$file = Yii::getAlias('@yii/apidoc/templates/' . $this->template . '/Renderer.php'); $rendererClass = 'yii\\apidoc\\templates\\' . $this->template . '\\Renderer';
$reflection = new FileReflector($file, true); if (!class_exists($rendererClass)) {
$reflection->process();
$classes = $reflection->getClasses();
if (empty($classes)) {
$this->stderr('Renderer not found.' . PHP_EOL); $this->stderr('Renderer not found.' . PHP_EOL);
exit(0);
} }
$rendererClass = reset($classes)->getName();
require($file);
return new $rendererClass(); return new $rendererClass();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment