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().
This commit is contained in:
Thomas Gelf 2014-06-17 12:55:43 +00:00
parent 25758332ab
commit 468b290277
2 changed files with 17 additions and 0 deletions

View File

@ -134,6 +134,7 @@ class ActionController extends Zend_Controller_Action
if ($this->requiresConfig() === false) { if ($this->requiresConfig() === false) {
if ($this->requiresLogin() === false) { if ($this->requiresLogin() === false) {
$this->view->tabs = new Tabs(); $this->view->tabs = new Tabs();
$this->moduleInit();
$this->init(); $this->init();
} else { } else {
$url = $this->getRequestUrl(); $url = $this->getRequestUrl();
@ -148,6 +149,10 @@ class ActionController extends Zend_Controller_Action
} }
} }
protected function moduleInit()
{
}
protected function getWindowId() protected function getWindowId()
{ {
if ($this->windowId === null) { if ($this->windowId === null) {

View File

@ -37,6 +37,13 @@ use Icinga\File\Csv;
*/ */
class Controller extends ActionController class Controller extends ActionController
{ {
/**
* The backend used for this controller
*
* @var Backend
*/
protected $backend;
/** /**
* Compact layout name * Compact layout name
* *
@ -47,6 +54,11 @@ class Controller extends ActionController
*/ */
protected $compactView; protected $compactView;
protected function moduleInit()
{
$this->backend = Backend::createBackend($this->_getParam('backend'));
}
protected function handleFormatRequest($query) protected function handleFormatRequest($query)
{ {
if ($this->compactView !== null && ($this->_getParam('view', false) === 'compact')) { if ($this->compactView !== null && ($this->_getParam('view', false) === 'compact')) {