mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-05-04 14:50:10 +02:00
parent
ec1ddd82b3
commit
444fdadf13
@ -408,22 +408,25 @@ class Manager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the module instance of the given module when it is loaded
|
* Get a module
|
||||||
*
|
*
|
||||||
* @param string $name The module name to return
|
* @param string $name Name of the module
|
||||||
|
* @param bool $assertLoaded Whether or not to throw an exception if the module hasn't been loaded
|
||||||
*
|
*
|
||||||
* @return Module
|
* @return Module
|
||||||
* @throws ProgrammingError When the module hasn't been loaded
|
* @throws ProgrammingError If the module hasn't been loaded
|
||||||
*/
|
*/
|
||||||
public function getModule($name)
|
public function getModule($name, $assertLoaded = true)
|
||||||
{
|
{
|
||||||
if (!$this->hasLoaded($name)) {
|
if ($this->hasLoaded($name)) {
|
||||||
throw new ProgrammingError(
|
return $this->loadedModules[$name];
|
||||||
'Cannot access module %s as it hasn\'t been loaded',
|
} elseif (! (bool) $assertLoaded) {
|
||||||
$name
|
return new Module($this->app, $name, $this->getModuleDir($name));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return $this->loadedModules[$name];
|
throw new ProgrammingError(
|
||||||
|
'Can\'t access module %s because it hasn\'t been loaded',
|
||||||
|
$name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user