dgifford/hooks-trait
Composer 安装命令:
composer require dgifford/hooks-trait
包简介
Trait providing methods for creating hooks.
README 文档
README
Adds the methods required to use hooks in a class, similar to how functions can be hooked into Wordpress.
Usage
Add a `use` statement at the start of the class to include the trait.
class Foo
{
Use dgifford\Traits\HooksTrait;
}
The `doHook` method adds a hook into the class. This method requires a name for the hook and a variable that the hook will act on.
$value = $this->doHook('my_hook_name', $value );
Additional arguments can be provided if hooked in functions require them.
$value = $this->doHook('my_hook_name', $value, $arguments );
Callbacks can then be hooked into the class with the `addHook` method, which accepts the hook name and a callable, such as a closure.
$foo->addHook( 'my_hook_name', function( $value, $arguments ) { return $value + 1; } );
统计信息
- 总下载量: 68
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2017-02-28