mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
Merge branch 'master' of https://github.com/top-think/framework
This commit is contained in:
@@ -91,10 +91,12 @@ class Hook
|
|||||||
* @param string $tag 标签名称
|
* @param string $tag 标签名称
|
||||||
* @param mixed $params 传入参数
|
* @param mixed $params 传入参数
|
||||||
* @param mixed $extra 额外参数
|
* @param mixed $extra 额外参数
|
||||||
* @return void
|
* @param bool $once 只获取一个有效返回值
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function listen($tag, &$params = null,$extra=null) {
|
public static function listen($tag, &$params = null, $extra = null, $once = false)
|
||||||
$result = true;
|
{
|
||||||
|
$results = [];
|
||||||
if (isset(self::$tags[$tag])) {
|
if (isset(self::$tags[$tag])) {
|
||||||
foreach (self::$tags[$tag] as $name) {
|
foreach (self::$tags[$tag] as $name) {
|
||||||
|
|
||||||
@@ -102,7 +104,11 @@ class Hook
|
|||||||
Debug::remark('behavior_start', 'time');
|
Debug::remark('behavior_start', 'time');
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = self::exec($name, $tag, $params,$extra);
|
$result = self::exec($name, $tag, $params, $extra);
|
||||||
|
|
||||||
|
if (!is_null($result) && $once) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
if (APP_DEBUG) {
|
if (APP_DEBUG) {
|
||||||
Debug::remark('behavior_end', 'time');
|
Debug::remark('behavior_end', 'time');
|
||||||
@@ -115,11 +121,12 @@ class Hook
|
|||||||
}
|
}
|
||||||
if (false === $result) {
|
if (false === $result) {
|
||||||
// 如果返回false 则中断行为执行
|
// 如果返回false 则中断行为执行
|
||||||
return;
|
break;
|
||||||
|
}
|
||||||
|
$results[] = $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return $once ? null : $results;
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user