mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
hook类的add方法增加first参数 支持把某个行为放到钩子的开头首先执行
This commit is contained in:
@@ -41,7 +41,6 @@ abstract class Driver
|
||||
protected $_linkID = null;
|
||||
// 数据库连接参数配置
|
||||
protected $config = [
|
||||
'db_like_fields' => '', //like字段自动替换为%%包裹
|
||||
'type' => '', // 数据库类型
|
||||
'hostname' => '127.0.0.1', // 服务器地址
|
||||
'database' => '', // 数据库名
|
||||
@@ -57,6 +56,7 @@ abstract class Driver
|
||||
'rw_separate' => false, // 数据库读写是否分离 主从式有效
|
||||
'master_num' => 1, // 读写分离后 主服务器数量
|
||||
'slave_no' => '', // 指定从服务器序号
|
||||
'db_like_fields' => '', //like字段自动替换为%%包裹
|
||||
];
|
||||
// 数据库表达式
|
||||
protected $exp = ['eq' => '=', 'neq' => '<>', 'gt' => '>', 'egt' => '>=', 'lt' => '<', 'elt' => '<=', 'notlike' => 'NOT LIKE', 'like' => 'LIKE', 'in' => 'IN', 'notin' => 'NOT IN', 'not in' => 'NOT IN', 'between' => 'BETWEEN', 'not between' => 'NOT BETWEEN', 'notbetween' => 'NOT BETWEEN'];
|
||||
|
||||
@@ -20,15 +20,18 @@ class Hook
|
||||
* 动态添加行为扩展到某个标签
|
||||
* @param string $tag 标签名称
|
||||
* @param mixed $behavior 行为名称
|
||||
* @param bool $first 是否放到开头执行
|
||||
* @return void
|
||||
*/
|
||||
public static function add($tag, $behavior)
|
||||
public static function add($tag, $behavior,$first=false)
|
||||
{
|
||||
if (!isset(self::$tags[$tag])) {
|
||||
self::$tags[$tag] = [];
|
||||
}
|
||||
if (is_array($behavior)) {
|
||||
self::$tags[$tag] = array_merge(self::$tags[$tag], $behavior);
|
||||
} elseif($first){
|
||||
array_unshift(self::$tags[$tag],$behavior);
|
||||
} else {
|
||||
self::$tags[$tag][] = $behavior;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user