/** * Register a hook object with the global HookHandler object. * * Allows for abstract calling of the hook. * * @param Hook $hook * * @return void */ public static function RegisterHook(Hook $hook) { $name = $hook->getName(); Core\Utilities\Logger\write_debug('Registering new hook [' . $name . ']'); if(isset(HookHandler::$RegisteredHooks[$name]) && FULL_DEBUG){ trigger_error('Registering hook that is already registered [' . $name . ']', E_USER_NOTICE); } HookHandler::$RegisteredHooks[$name] = $hook; //var_dump(self::$EarlyRegisteredHooks); // Attach any bindings that may have existed. if (isset(self::$EarlyRegisteredHooks[$name])) { foreach (self::$EarlyRegisteredHooks[$name] as $b) { $hook->attach($b['call']); } unset(self::$EarlyRegisteredHooks[$name]); } }
/** * Check if any hook is registered on given name * @param Hook $hook * @return boolean */ public static function isHookRegistered(Hook $hookToCheck) { if (isset(static::$hooks[$hookToCheck->getName()]) and !empty(static::$hooks[$hookToCheck->getName()])) { foreach (static::$hooks[$hookToCheck->getName()] as $hook) { if ($hookToCheck === $hook) { return true; } } } return false; }