redirect助手函数和controller类的redirect方法增加with参数

This commit is contained in:
thinkphp
2017-02-02 14:26:06 +08:00
parent ca228203c9
commit 3f0fa05a7c
2 changed files with 6 additions and 4 deletions

View File

@@ -495,15 +495,16 @@ if (!function_exists('redirect')) {
* @param mixed $url 重定向地址 支持Url::build方法的地址 * @param mixed $url 重定向地址 支持Url::build方法的地址
* @param array|integer $params 额外参数 * @param array|integer $params 额外参数
* @param integer $code 状态码 * @param integer $code 状态码
* @param array $with 隐式传参
* @return \think\response\Redirect * @return \think\response\Redirect
*/ */
function redirect($url = [], $params = [], $code = 302) function redirect($url = [], $params = [], $code = 302, $with = [])
{ {
if (is_integer($params)) { if (is_integer($params)) {
$code = $params; $code = $params;
$params = []; $params = [];
} }
return Response::create($url, 'redirect', $code)->params($params); return Response::create($url, 'redirect', $code)->params($params)->with($with);
} }
} }

View File

@@ -131,16 +131,17 @@ trait Jump
* @param string $url 跳转的URL表达式 * @param string $url 跳转的URL表达式
* @param array|integer $params 其它URL参数 * @param array|integer $params 其它URL参数
* @param integer $code http code * @param integer $code http code
* @param array $with 隐式传参
* @return void * @return void
*/ */
protected function redirect($url, $params = [], $code = 302) protected function redirect($url, $params = [], $code = 302, $with = [])
{ {
$response = new Redirect($url); $response = new Redirect($url);
if (is_integer($params)) { if (is_integer($params)) {
$code = $params; $code = $params;
$params = []; $params = [];
} }
$response->code($code)->params($params); $response->code($code)->params($params)->with($with);
throw new HttpResponseException($response); throw new HttpResponseException($response);
} }