diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index c9403db6f3..9066f4482c 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -324,6 +324,21 @@ protected function setupModuleManager() 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 * diff --git a/library/Icinga/Application/EmbeddedWeb.php b/library/Icinga/Application/EmbeddedWeb.php index 6a160017c5..0dd8b5d5c8 100644 --- a/library/Icinga/Application/EmbeddedWeb.php +++ b/library/Icinga/Application/EmbeddedWeb.php @@ -31,6 +31,7 @@ protected function bootstrap() ->setupErrorHandling() ->setupTimezone() ->setupModuleManager() + ->loadCoreModules() ->loadEnabledModules(); } } diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php index b2d51a9a5d..984e528d2f 100644 --- a/library/Icinga/Application/Modules/Manager.php +++ b/library/Icinga/Application/Modules/Manager.php @@ -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 @@ private function detectEnabledModules() } /** - * 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 @@ public function enableModule($name) 'Cannot enable module "%s". Module is not installed.', $name ); + } elseif (in_array($name, $this->coreModules)) { + return $this; } clearstatcache(true); @@ -427,7 +455,7 @@ public function getModuleInfo() } $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], diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index d43b1d34d9..23b0634a03 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -92,6 +92,7 @@ protected function bootstrap() ->setupZendMvc() ->setupFormNamespace() ->setupModuleManager() + ->loadCoreModules() ->loadEnabledModules() ->setupRoute() ->setupPagination(); diff --git a/modules/translation/library/Translation/Util/GettextTranslationHelper.php b/modules/translation/library/Translation/Util/GettextTranslationHelper.php index 5702def85b..0d5a950e17 100644 --- a/modules/translation/library/Translation/Util/GettextTranslationHelper.php +++ b/modules/translation/library/Translation/Util/GettextTranslationHelper.php @@ -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; }