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