bootstrapping: allow to load modules neither...

...enabled nor installed by passing their base directory. In favour
of this parameter I dropped the possibility to inject a Module class
for testing purposes. There is no such test and I see no point in
doing so.

refs #6411
This commit is contained in:
Thomas Gelf 2014-06-04 22:57:50 +00:00
parent e076d2d1d6
commit 0e6aecbd43
1 changed files with 6 additions and 7 deletions

View File

@ -196,23 +196,22 @@ class Manager
/**
* Try to load the module and register it in the application
*
* @param string $name The name of the module to load
* @param mixed $moduleBase Alternative class to use instead of \Icinga\Application\Modules\Module for
* instantiating modules, used for testing
* @param string $name The name of the module to load
* @param mixed $basedir Optional module base directory
*
* @return self
* @return self
*/
public function loadModule($name, $moduleBase = null)
public function loadModule($name, $basedir = null)
{
if ($this->hasLoaded($name)) {
return $this;
}
$module = null;
if ($moduleBase === null) {
if ($basedir === null) {
$module = new Module($this->app, $name, $this->getModuleDir($name));
} else {
$module = new $moduleBase($this->app, $name, $this->getModuleDir($name));
$module = new Module($this->app, $name, $basedir);
}
$module->register();
$this->loadedModules[$name] = $module;