PHP Class think\Hook

Show file Open project: top-think/framework Class Usage Examples

Public Methods

Method Description
add ( string $tag, mixed $behavior, boolean $first = false ) : void 动态添加行为扩展到某个标签
exec ( mixed $class, string $tag = '', Mixed &$params = null, mixed $extra = null ) : mixed 执行某个行为
get ( string $tag = '' ) : array 获取插件信息
import ( array $tags, boolean $recursive = true ) 批量导入插件
listen ( string $tag, mixed &$params = null, mixed $extra = null, boolean $once = false ) : mixed 监听标签的行为

Method Details

add() public static method

动态添加行为扩展到某个标签
public static add ( string $tag, mixed $behavior, boolean $first = false ) : void
$tag string 标签名称
$behavior mixed 行为名称
$first boolean 是否放到开头执行
return void

exec() public static method

执行某个行为
public static exec ( mixed $class, string $tag = '', Mixed &$params = null, mixed $extra = null ) : mixed
$class mixed 要执行的行为
$tag string 方法名(标签名)
$params Mixed 传人的参数
$extra mixed 额外参数
return mixed

get() public static method

获取插件信息
public static get ( string $tag = '' ) : array
$tag string 插件位置 留空获取全部
return array

import() public static method

批量导入插件
public static import ( array $tags, boolean $recursive = true )
$tags array 插件信息
$recursive boolean 是否递归合并

listen() public static method

监听标签的行为
public static listen ( string $tag, mixed &$params = null, mixed $extra = null, boolean $once = false ) : mixed
$tag string 标签名称
$params mixed 传入参数
$extra mixed 额外参数
$once boolean 只获取一个有效返回值
return mixed