diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index 2090ab51f..5f91b0891 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -1248,12 +1248,35 @@ class Module */ protected function registerHook($name, $class, $key = null) { - if ($key === null) { - $key = $class; + return $this->provideHook($name, $class, $key); + } + + protected function slashesToNamespace($class) + { + $list = explode('/', $class); + foreach ($list as &$part) { + $part = ucfirst($part); } - Hook::register($name, $key, $class); + return implode('\\', $list); + } + // deprecate $key + protected function provideHook($name, $implementation = null, $key = null) + { + if ($implementation === null) { + $implementation = $name; + } + + if (strpos($implementation, '\\') === false) { + $class = $this->getNamespace() + . '\\Hook\\' + . $this->slashesToNamespace($implementation); + } else { + $class = $implementation; + } + + Hook::register($name, $implementation, $class); return $this; }