Add support for "core" modules and make the setup module such a module

refs #7163
This commit is contained in:
Johannes Meyer 2014-11-10 17:34:49 +01:00
parent 6b2f434f32
commit 8af13f564b
5 changed files with 48 additions and 3 deletions

View File

@ -324,6 +324,21 @@ abstract class ApplicationBootstrap
return $this;
}
/**
* Load all core modules
*
* @return self
*/
protected function loadCoreModules()
{
try {
$this->moduleManager->loadCoreModules();
} catch (NotReadableError $e) {
Logger::error(new IcingaException('Cannot load core modules. An exception was thrown:', $e));
}
return $this;
}
/**
* Load all enabled modules
*

View File

@ -31,6 +31,7 @@ class EmbeddedWeb extends ApplicationBootstrap
->setupErrorHandling()
->setupTimezone()
->setupModuleManager()
->loadCoreModules()
->loadEnabledModules();
}
}

View File

@ -67,6 +67,18 @@ class Manager
*/
private $modulePaths = array();
/**
* The core modules
*
* Core modules do not need to be enabled to load and cannot be disabled
* by the user. This must not be writable programmatically!
*
* @var array
*/
private $coreModules = array(
'setup'
);
/**
* Create a new instance of the module manager
*
@ -157,7 +169,21 @@ class Manager
}
/**
* Try to set all enabled modules in loaded sate
* Try to set all core modules in loaded state
*
* @return self
* @see Manager::loadModule()
*/
public function loadCoreModules()
{
foreach ($this->coreModules as $name) {
$this->loadModule($name);
}
return $this;
}
/**
* Try to set all enabled modules in loaded state
*
* @return self
* @see Manager::loadModule()
@ -211,6 +237,8 @@ class Manager
'Cannot enable module "%s". Module is not installed.',
$name
);
} elseif (in_array($name, $this->coreModules)) {
return $this;
}
clearstatcache(true);
@ -427,7 +455,7 @@ class Manager
}
$installed = $this->listInstalledModules();
foreach ($installed as $name) {
foreach (array_diff($installed, $this->coreModules) as $name) {
$info[$name] = (object) array(
'name' => $name,
'path' => $this->installedBaseDirs[$name],

View File

@ -92,6 +92,7 @@ class Web extends ApplicationBootstrap
->setupZendMvc()
->setupFormNamespace()
->setupModuleManager()
->loadCoreModules()
->loadEnabledModules()
->setupRoute()
->setupPagination();

View File

@ -101,7 +101,7 @@ class GettextTranslationHelper
*/
public function __construct(ApplicationBootstrap $bootstrap, $locale)
{
$this->moduleMgr = $bootstrap->getModuleManager()->loadEnabledModules();
$this->moduleMgr = $bootstrap->getModuleManager()->loadCoreModules()->loadEnabledModules();
$this->appDir = $bootstrap->getApplicationDir();
$this->locale = $locale;
}