modules/doc: Implement doc/module/$moduleName URLs

refs #4820
This commit is contained in:
Eric Lippmann 2014-05-23 14:06:28 +02:00
parent 74ea4d19b8
commit 40c2c64985
1 changed files with 8 additions and 19 deletions

View File

@ -1,5 +1,4 @@
<?php
// @codingStandardsIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
@ -9,39 +8,29 @@ use Icinga\Module\Doc\Controller as DocController;
class Doc_ModuleController extends DocController
{
/**
* Display module documentations index
* List available modules
*/
public function indexAction()
{
$this->view->enabledModules = Icinga::app()->getModuleManager()->listEnabledModules();
}
/**
* Display a module's documentation
*/
public function viewAction()
{
$this->populateView($this->getParam('name'));
}
/**
* Provide run-time dispatching of module documentation
*
* @param string $methodName
* @param array $args
* @param string $methodName
* @param array $args
*
* @return mixed
*/
public function __call($methodName, $args)
{
// TODO(el): Setup routing to retrieve module name as param and point route to moduleAction
$moduleManager = Icinga::app()->getModuleManager();
$moduleName = substr($methodName, 0, -6); // Strip 'Action' suffix
if (!$moduleManager->hasEnabled($moduleName)) {
// TODO(el): Throw a not found exception once the code has been moved to the moduleAction (see TODO above)
$moduleManager = Icinga::app()->getModuleManager();
$moduleName = substr($methodName, 0, -6); // Strip 'Action' suffix
if (! $moduleManager->hasEnabled($moduleName)) {
// TODO(el): Distinguish between not enabled and not installed
return parent::__call($methodName, $args);
}
$this->_helper->redirector->gotoSimpleAndExit('view', null, null, array('name' => $moduleName));
$this->renderDocAndToc($moduleName);
}
}
// @codingStandardsIgnoreEnd