38 $this->context = $context;
39 $this->currentHook = array();
49 public function register($module, $hookName)
51 if (!\
Tools\ModuleManager::isInstalling())
52 throw new \
Exception(
"You can only register hooks while installing");
62 public function trigger($hookName, $params =null)
64 if (empty($this->hooks[$hookName]))
66 $hookEvent =
new HookEvent($hookName, $this->context, $params);
67 array_push($this->currentHook, $hookEvent);
69 foreach ($this->hooks[$hookName] as $module_id)
71 $module = $this->context->moduleManager->getModuleFromId($module_id);
74 $module->doAction($hookEvent);
77 array_pop($this->currentHook);
88 foreach ($this->currentHook as $i)
89 if ($i->hookName == $hookName)
100 $this->hooks = array();
101 foreach ($hookEntities as $i)
102 $this->hooks[$i->hookName][] = (int) $i->module_id;
112 case "currentHook":
return end($this->currentHook);
114 throw new \Exception(
"Cannot access attribute {$key}");