本文整理汇总了PHP中Hook::attach方法的典型用法代码示例。如果您正苦于以下问题:PHP Hook::attach方法的具体用法?PHP Hook::attach怎么用?PHP Hook::attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hook
的用法示例。
在下文中一共展示了Hook::attach方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: factory
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;
}
示例2: RegisterHook
/**
* 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]);
}
}