mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 08:14:03 +02:00
Module: add new provideHook method
This commit is contained in:
parent
b7189382fb
commit
380f11d9c2
@ -1248,12 +1248,35 @@ class Module
|
|||||||
*/
|
*/
|
||||||
protected function registerHook($name, $class, $key = null)
|
protected function registerHook($name, $class, $key = null)
|
||||||
{
|
{
|
||||||
if ($key === null) {
|
return $this->provideHook($name, $class, $key);
|
||||||
$key = $class;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Hook::register($name, $key, $class);
|
protected function slashesToNamespace($class)
|
||||||
|
{
|
||||||
|
$list = explode('/', $class);
|
||||||
|
foreach ($list as &$part) {
|
||||||
|
$part = ucfirst($part);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user