本文整理匯總了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]);
}
}