mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02:48 +08:00
改进start.php环境变量处理 改进hook类方法执行返回值
This commit is contained in:
@@ -90,10 +90,11 @@ class Hook
|
|||||||
* 监听标签的行为
|
* 监听标签的行为
|
||||||
* @param string $tag 标签名称
|
* @param string $tag 标签名称
|
||||||
* @param mixed $params 传入参数
|
* @param mixed $params 传入参数
|
||||||
|
* @param mixed $extra 额外参数
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function listen($tag, &$params = null)
|
public static function listen($tag, &$params = null,$extra=null) {
|
||||||
{
|
$result = true;
|
||||||
if (isset(self::$tags[$tag])) {
|
if (isset(self::$tags[$tag])) {
|
||||||
foreach (self::$tags[$tag] as $name) {
|
foreach (self::$tags[$tag] as $name) {
|
||||||
|
|
||||||
@@ -101,7 +102,7 @@ class Hook
|
|||||||
Debug::remark('behavior_start', 'time');
|
Debug::remark('behavior_start', 'time');
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = self::exec($name, $tag, $params);
|
$result = self::exec($name, $tag, $params,$extra);
|
||||||
|
|
||||||
if (APP_DEBUG) {
|
if (APP_DEBUG) {
|
||||||
Debug::remark('behavior_end', 'time');
|
Debug::remark('behavior_end', 'time');
|
||||||
@@ -118,7 +119,7 @@ class Hook
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,17 +127,18 @@ class Hook
|
|||||||
* @param mixed $class 要执行的行为
|
* @param mixed $class 要执行的行为
|
||||||
* @param string $tag 方法名(标签名)
|
* @param string $tag 方法名(标签名)
|
||||||
* @param Mixed $params 传人的参数
|
* @param Mixed $params 传人的参数
|
||||||
|
* @param mixed $extra 额外参数
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function exec($class, $tag = '', &$params = null)
|
public static function exec($class, $tag = '', &$params = null,$extra=null)
|
||||||
{
|
{
|
||||||
if ($class instanceof \Closure) {
|
if ($class instanceof \Closure) {
|
||||||
$result = call_user_func_array($class, [ & $params]);
|
$result = call_user_func_array($class, [ & $params,$extra]);
|
||||||
} elseif (is_object($class)) {
|
} elseif (is_object($class)) {
|
||||||
$result = call_user_func_array([$class, $tag], [ & $params]);
|
$result = call_user_func_array([$class, $tag], [ & $params,$extra]);
|
||||||
} else {
|
} else {
|
||||||
$obj = new $class();
|
$obj = new $class();
|
||||||
$result = ($tag && is_callable([$obj, $tag])) ? $obj->$tag($params) : $obj->run($params);
|
$result = ($tag && is_callable([$obj, $tag])) ? $obj->$tag($params,$extra) : $obj->run($params,$extra);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class Response
|
|||||||
$data = $this->output($data);
|
$data = $this->output($data);
|
||||||
|
|
||||||
// 监听response_data
|
// 监听response_data
|
||||||
Hook::listen('response_data', $data);
|
Hook::listen('response_data', $data, $this);
|
||||||
|
|
||||||
// 发送头部信息
|
// 发送头部信息
|
||||||
if (!headers_sent() && !empty($this->header)) {
|
if (!headers_sent() && !empty($this->header)) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ if (is_file(ROOT_PATH . 'env' . EXT)) {
|
|||||||
$env = include ROOT_PATH . 'env' . EXT;
|
$env = include ROOT_PATH . 'env' . EXT;
|
||||||
foreach ($env as $key => $val) {
|
foreach ($env as $key => $val) {
|
||||||
$name = ENV_PREFIX . $key;
|
$name = ENV_PREFIX . $key;
|
||||||
putenv("$name=$val");
|
putenv("$name=".var_export($var,true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 自动识别调试模式
|
// 自动识别调试模式
|
||||||
|
|||||||
Reference in New Issue
Block a user