From c6ebe857824af1ec7518e5d8263aadbf2ee58037 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Wed, 17 Jul 2013 14:47:51 +0200 Subject: [PATCH] Command masks: Implement list over all implemented commands [WIP] refs #4355 --- .../controllers/CommandController.php | 27 ++++++++++--------- .../views/scripts/command/list.phtml | 8 ++++++ 2 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 modules/monitoring/application/views/scripts/command/list.phtml diff --git a/modules/monitoring/application/controllers/CommandController.php b/modules/monitoring/application/controllers/CommandController.php index 9ab70a5d9..8617e504e 100644 --- a/modules/monitoring/application/controllers/CommandController.php +++ b/modules/monitoring/application/controllers/CommandController.php @@ -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; } // ------------------------------------------------------------------------ diff --git a/modules/monitoring/application/views/scripts/command/list.phtml b/modules/monitoring/application/views/scripts/command/list.phtml new file mode 100644 index 000000000..f37ae4db1 --- /dev/null +++ b/modules/monitoring/application/views/scripts/command/list.phtml @@ -0,0 +1,8 @@ +

+ \ No newline at end of file