From 468b290277c1f448e411db93537c411762835e83 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 17 Jun 2014 12:55:43 +0000 Subject: [PATCH] Monitoring\Controller: provide $this->backend Every monitoring controller needs $backend, so why declaring it over and over again. Created "moduleInit" dummy function in our base action controller to allow such implementations without polluting init(). --- library/Icinga/Web/Controller/ActionController.php | 5 +++++ modules/monitoring/library/Monitoring/Controller.php | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 7593db752..2cee1e9d3 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -134,6 +134,7 @@ class ActionController extends Zend_Controller_Action if ($this->requiresConfig() === false) { if ($this->requiresLogin() === false) { $this->view->tabs = new Tabs(); + $this->moduleInit(); $this->init(); } else { $url = $this->getRequestUrl(); @@ -148,6 +149,10 @@ class ActionController extends Zend_Controller_Action } } + protected function moduleInit() + { + } + protected function getWindowId() { if ($this->windowId === null) { diff --git a/modules/monitoring/library/Monitoring/Controller.php b/modules/monitoring/library/Monitoring/Controller.php index a5d17b89e..666101263 100644 --- a/modules/monitoring/library/Monitoring/Controller.php +++ b/modules/monitoring/library/Monitoring/Controller.php @@ -37,6 +37,13 @@ use Icinga\File\Csv; */ class Controller extends ActionController { + /** + * The backend used for this controller + * + * @var Backend + */ + protected $backend; + /** * Compact layout name * @@ -47,6 +54,11 @@ class Controller extends ActionController */ protected $compactView; + protected function moduleInit() + { + $this->backend = Backend::createBackend($this->_getParam('backend')); + } + protected function handleFormatRequest($query) { if ($this->compactView !== null && ($this->_getParam('view', false) === 'compact')) {