Example #1
0
 static function factory($command, $name, $is_command, $regex, $func, $category)
 {
     $hook = new Hook();
     $hook->command = $command;
     $hook->name = $name;
     $hook->is_command = $is_command == true ? true : false;
     $hook->regex = $regex != '' ? $regex : "/^{$command}\$/";
     $hook->func = $func;
     $hook->category = $category;
     $hook->attach($hook->category);
     return $hook;
 }
	/**
	 * 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]);
		}
	}