From 7a9eeba5652c864c95f38e4805e8a5f7ef8d2cac Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 25 May 2016 14:26:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Bstart.php=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E5=A4=84=E7=90=86=20=E6=94=B9=E8=BF=9Bhook?= =?UTF-8?q?=E7=B1=BB=E6=96=B9=E6=B3=95=E6=89=A7=E8=A1=8C=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Hook.php | 18 ++++++++++-------- library/think/Response.php | 2 +- start.php | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/library/think/Hook.php b/library/think/Hook.php index b2cb0471..82834542 100644 --- a/library/think/Hook.php +++ b/library/think/Hook.php @@ -90,10 +90,11 @@ class Hook * 监听标签的行为 * @param string $tag 标签名称 * @param mixed $params 传入参数 + * @param mixed $extra 额外参数 * @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])) { foreach (self::$tags[$tag] as $name) { @@ -101,7 +102,7 @@ class Hook Debug::remark('behavior_start', 'time'); } - $result = self::exec($name, $tag, $params); + $result = self::exec($name, $tag, $params,$extra); if (APP_DEBUG) { Debug::remark('behavior_end', 'time'); @@ -118,7 +119,7 @@ class Hook } } } - return; + return $result; } /** @@ -126,17 +127,18 @@ class Hook * @param mixed $class 要执行的行为 * @param string $tag 方法名(标签名) * @param Mixed $params 传人的参数 + * @param mixed $extra 额外参数 * @return mixed */ - public static function exec($class, $tag = '', &$params = null) + public static function exec($class, $tag = '', &$params = null,$extra=null) { if ($class instanceof \Closure) { - $result = call_user_func_array($class, [ & $params]); + $result = call_user_func_array($class, [ & $params,$extra]); } elseif (is_object($class)) { - $result = call_user_func_array([$class, $tag], [ & $params]); + $result = call_user_func_array([$class, $tag], [ & $params,$extra]); } else { $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; } diff --git a/library/think/Response.php b/library/think/Response.php index 13a5dc76..eb70ad8f 100644 --- a/library/think/Response.php +++ b/library/think/Response.php @@ -101,7 +101,7 @@ class Response $data = $this->output($data); // 监听response_data - Hook::listen('response_data', $data); + Hook::listen('response_data', $data, $this); // 发送头部信息 if (!headers_sent() && !empty($this->header)) { diff --git a/start.php b/start.php index b8fa8b9b..b5a209ee 100644 --- a/start.php +++ b/start.php @@ -21,7 +21,7 @@ if (is_file(ROOT_PATH . 'env' . EXT)) { $env = include ROOT_PATH . 'env' . EXT; foreach ($env as $key => $val) { $name = ENV_PREFIX . $key; - putenv("$name=$val"); + putenv("$name=".var_export($var,true)); } } // 自动识别调试模式