/** * */ protected function installHooks() { $hooksFile = $this->moduleDirectory . '/install/hooks.json'; $moduleHooksFile = $this->moduleDirectory . '/install/registeredHooks.json'; if (file_exists($hooksFile)) { $hooks = json_decode(file_get_contents($hooksFile), true); foreach ($hooks as $hook) { Hook::insertHook($hook['name'], $hook['description']); } } if (file_exists($moduleHooksFile)) { $moduleHooks = json_decode(file_get_contents($moduleHooksFile), true); foreach ($moduleHooks as $moduleHook) { Hook::register($this->moduleId, $moduleHook['name'], $moduleHook['moduleHook'], $moduleHook['moduleHookDescription']); } } }
public function testRegisterException() { Hook::register(1, 'displayLeftMenu', 'displayTest', 'a description'); $this->setExpectedException("\\Centreon\\Internal\\Exception", "Hook already registered"); Hook::register(1, 'displayLeftMenu', 'displayTest', 'a description'); }