From 3f0fa05a7cf7b19e165760309af76a3d5c4c9e7d Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 2 Feb 2017 14:26:06 +0800 Subject: [PATCH] =?UTF-8?q?redirect=E5=8A=A9=E6=89=8B=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=92=8Ccontroller=E7=B1=BB=E7=9A=84redirect=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0with=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper.php | 5 +++-- library/traits/controller/Jump.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/helper.php b/helper.php index 543942be..da0dc9c5 100644 --- a/helper.php +++ b/helper.php @@ -495,15 +495,16 @@ if (!function_exists('redirect')) { * @param mixed $url 重定向地址 支持Url::build方法的地址 * @param array|integer $params 额外参数 * @param integer $code 状态码 + * @param array $with 隐式传参 * @return \think\response\Redirect */ - function redirect($url = [], $params = [], $code = 302) + function redirect($url = [], $params = [], $code = 302, $with = []) { if (is_integer($params)) { $code = $params; $params = []; } - return Response::create($url, 'redirect', $code)->params($params); + return Response::create($url, 'redirect', $code)->params($params)->with($with); } } diff --git a/library/traits/controller/Jump.php b/library/traits/controller/Jump.php index 51f4281f..6e6f2dec 100644 --- a/library/traits/controller/Jump.php +++ b/library/traits/controller/Jump.php @@ -131,16 +131,17 @@ trait Jump * @param string $url 跳转的URL表达式 * @param array|integer $params 其它URL参数 * @param integer $code http code + * @param array $with 隐式传参 * @return void */ - protected function redirect($url, $params = [], $code = 302) + protected function redirect($url, $params = [], $code = 302, $with = []) { $response = new Redirect($url); if (is_integer($params)) { $code = $params; $params = []; } - $response->code($code)->params($params); + $response->code($code)->params($params)->with($with); throw new HttpResponseException($response); }