diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index d4f9514bb..d9bb1d483 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -86,24 +86,18 @@ class ActionController extends Zend_Controller_Action protected $params; - // TODO: This would look better if we had a ModuleActionController public function Config($file = null) { - if ($this->config === null) { - $module = $this->getRequest()->getModuleName(); - if ($module === 'default') { - if ($file === null) { - $this->config = Config::app(); - } else { - $this->config = Config::app($file); - } - } else { - if ($file === null) { - $this->config = Config::module($module); - } else { - $this->config = Config::module($module, $file); - } + if ($file === null) { + if ($this->config === null) { + $this->config = Config::app(); } + return $this->config; + } else { + if (! array_key_exists($file, $this->configs)) { + $this->configs[$file] = Config::module($module, $file); + } + return $this->configs[$file]; } return $this->config; } diff --git a/library/Icinga/Web/Controller/ModuleActionController.php b/library/Icinga/Web/Controller/ModuleActionController.php new file mode 100644 index 000000000..d718cc19e --- /dev/null +++ b/library/Icinga/Web/Controller/ModuleActionController.php @@ -0,0 +1,29 @@ +getRequest()->getModuleName(); + + $this->moduleName = $module; + + if ($tile === null) { + if ($this->config === null) { + $this->config = Config::module($module); + } + return $this->config; + } else { + if (! array_key_exists($file, $this->configs)) { + $this->configs[$file] = Config::module($module, $file); + } + return $this->configs[$file]; + } + } +}