Command masks: Implement list over all implemented commands [WIP]

refs #4355
This commit is contained in:
Marius Hein 2013-07-17 14:47:51 +02:00
parent 03f4a8eceb
commit c6ebe85782
2 changed files with 23 additions and 12 deletions

View File

@ -91,8 +91,10 @@ class Monitoring_CommandController extends ModuleActionController
} }
} }
// Reduce template writing mess if ($this->getRequest()->getActionName() !== 'list') {
$this->_helper->viewRenderer->setRender(self::DEFAULT_VIEW_SCRIPT); // Reduce template writing mess
$this->_helper->viewRenderer->setRender(self::DEFAULT_VIEW_SCRIPT);
}
} }
/** /**
@ -120,19 +122,20 @@ class Monitoring_CommandController extends ModuleActionController
} }
/** /**
* Getter for request parameters * Displays a list of all commands
* @param string $name
* @param bool $mandatory
* @return mixed
* @throws Icinga\Exception\MissingParameterException
*/ */
private function getParameter($name, $mandatory = true) public function listAction()
{ {
$value = $this->_request->getParam($name); $reflection = new ReflectionObject($this);
if ($mandatory && !$value) { $commands = array();
throw new MissingParameterException("Missing parameter $name"); $methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC);
foreach ($methods as $method) {
$name = $method->getName();
if ($name !== 'listAction' && preg_match('/Action$/', $name)) {
$commands[] = preg_replace('/Action$/', '', $name);
}
} }
return $value; $this->view->commands = $commands;
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------

View File

@ -0,0 +1,8 @@
<h4><?= t('List of supported commands'); ?></h4>
<ul>
<?php foreach($this->commands as $command): ?>
<li>
<?= $this->qlink($command, 'monitoring/command/'. $command); ?>
</li>
<?php endforeach; ?>
</ul>