modules: Register controller namesoace in Module::registerWebIntegration()

Else we get an exception when loading modules on the CLI because Zend classes are not autoloaded.

refs #5786
This commit is contained in:
Eric Lippmann 2015-08-20 16:24:12 +02:00
parent fba9780405
commit f24449b225

View File

@ -958,14 +958,6 @@ class Module
$loader->registerNamespace('Icinga\\Module\\' . $moduleName. '\\Forms', $moduleFormDir); $loader->registerNamespace('Icinga\\Module\\' . $moduleName. '\\Forms', $moduleFormDir);
} }
$moduleControllerDir = $this->getControllerDir();
if (is_dir($moduleControllerDir)) {
$loader->registerNamespace(
'Icinga\\Module\\' . $moduleName . '\\' . Dispatcher::CONTROLLER_NAMESPACE,
$moduleControllerDir
);
}
$this->registeredAutoloader = true; $this->registeredAutoloader = true;
return $this; return $this;
@ -1025,18 +1017,22 @@ class Module
*/ */
protected function registerWebIntegration() protected function registerWebIntegration()
{ {
if (!$this->app->isWeb()) { if (! $this->app->isWeb()) {
return $this; return $this;
} }
$moduleControllerDir = $this->getControllerDir();
if (file_exists($this->controllerdir) && is_dir($this->controllerdir)) { if (is_dir($moduleControllerDir)) {
$this->app->getfrontController()->addControllerDirectory( $this->app->getfrontController()->addControllerDirectory(
$this->controllerdir, $moduleControllerDir,
$this->name $this->getName()
);
$this->app->getLoader()->registerNamespace(
'Icinga\\Module\\' . ucfirst($this->getName()) . '\\' . Dispatcher::CONTROLLER_NAMESPACE,
$moduleControllerDir
); );
} }
$this
$this->registerLocales() ->registerLocales()
->registerRoutes(); ->registerRoutes();
return $this; return $this;
} }