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

refs 
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
modules/monitoring/application
controllers
views/scripts/command

View File

@ -91,8 +91,10 @@ class Monitoring_CommandController extends ModuleActionController
}
}
// Reduce template writing mess
$this->_helper->viewRenderer->setRender(self::DEFAULT_VIEW_SCRIPT);
if ($this->getRequest()->getActionName() !== 'list') {
// 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
* @param string $name
* @param bool $mandatory
* @return mixed
* @throws Icinga\Exception\MissingParameterException
* Displays a list of all commands
*/
private function getParameter($name, $mandatory = true)
public function listAction()
{
$value = $this->_request->getParam($name);
if ($mandatory && !$value) {
throw new MissingParameterException("Missing parameter $name");
$reflection = new ReflectionObject($this);
$commands = array();
$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>