控制器的error success result redirect方法均不需要使用return

This commit is contained in:
thinkphp
2016-07-24 20:56:21 +08:00
parent 92e5ca0226
commit bab4398552

View File

@@ -27,11 +27,11 @@ trait Jump
/** /**
* 操作成功跳转的快捷方法 * 操作成功跳转的快捷方法
* @access protected * @access protected
* @param mixed $msg 提示信息 * @param mixed $msg 提示信息
* @param string $url 跳转的URL地址 * @param string $url 跳转的URL地址
* @param mixed $data 返回的数据 * @param mixed $data 返回的数据
* @param integer $wait 跳转等待时间 * @param integer $wait 跳转等待时间
* @return array * @return void
*/ */
protected function success($msg = '', $url = null, $data = '', $wait = 3) protected function success($msg = '', $url = null, $data = '', $wait = 3)
{ {
@@ -58,16 +58,17 @@ trait Jump
$result = ViewTemplate::instance(Config::get('template'), Config::get('view_replace_str')) $result = ViewTemplate::instance(Config::get('template'), Config::get('view_replace_str'))
->fetch(Config::get('dispatch_success_tmpl'), $result); ->fetch(Config::get('dispatch_success_tmpl'), $result);
} }
return Response::create($result, $type); $response = Response::create($result, $type);
throw new HttpResponseException($response);
} }
/** /**
* 操作错误跳转的快捷方法 * 操作错误跳转的快捷方法
* @access protected * @access protected
* @param mixed $msg 提示信息 * @param mixed $msg 提示信息
* @param string $url 跳转的URL地址 * @param string $url 跳转的URL地址
* @param mixed $data 返回的数据 * @param mixed $data 返回的数据
* @param integer $wait 跳转等待时间 * @param integer $wait 跳转等待时间
* @return void * @return void
*/ */
protected function error($msg = '', $url = null, $data = '', $wait = 3) protected function error($msg = '', $url = null, $data = '', $wait = 3)
@@ -102,11 +103,11 @@ trait Jump
/** /**
* 返回封装后的API数据到客户端 * 返回封装后的API数据到客户端
* @access protected * @access protected
* @param mixed $data 要返回的数据 * @param mixed $data 要返回的数据
* @param integer $code 返回的code * @param integer $code 返回的code
* @param mixed $msg 提示信息 * @param mixed $msg 提示信息
* @param string $type 返回数据格式 * @param string $type 返回数据格式
* @return mixed * @return void
*/ */
protected function result($data, $code = 0, $msg = '', $type = '') protected function result($data, $code = 0, $msg = '', $type = '')
{ {
@@ -116,16 +117,17 @@ trait Jump
'time' => $_SERVER['REQUEST_TIME'], 'time' => $_SERVER['REQUEST_TIME'],
'data' => $data, 'data' => $data,
]; ];
$type = $type ?: $this->getResponseType(); $type = $type ?: $this->getResponseType();
return Response::create($result, $type); $response = Response::create($result, $type);
throw new HttpResponseException($response);
} }
/** /**
* URL重定向 * URL重定向
* @access protected * @access protected
* @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
* @return void * @return void
*/ */
protected function redirect($url, $params = [], $code = 302) protected function redirect($url, $params = [], $code = 302)