mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
改进Response类 增加think\response\View类 用于渲染模板响应输出
This commit is contained in:
31
helper.php
31
helper.php
@@ -336,20 +336,6 @@ function trace($log = '[think]', $level = 'log')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染模板输出
|
||||
* @param string $template 模板文件
|
||||
* @param array $vars 模板变量
|
||||
* @param integer $code 状态码
|
||||
* @param string $type 输出类型
|
||||
* @return \think\Response
|
||||
*/
|
||||
function view($template = '', $vars = [], $code = 200)
|
||||
{
|
||||
$response = new \think\response\Html();
|
||||
return $response->data($template)->render(true)->vars($vars)->code($code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 路由注册
|
||||
* @param string $rule 路由规则
|
||||
@@ -379,9 +365,22 @@ function request()
|
||||
* @param array $options 参数
|
||||
* @return \think\Response
|
||||
*/
|
||||
function response($type = '', $options = [])
|
||||
function response($data = [], $type = '', $options = [])
|
||||
{
|
||||
return Response::create($type, $options);
|
||||
return new Response($data, $type, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染模板输出
|
||||
* @param string $template 模板文件
|
||||
* @param array $vars 模板变量
|
||||
* @param integer $code 状态码
|
||||
* @return \think\response\View
|
||||
*/
|
||||
function view($template = '', $vars = [], $code = 200)
|
||||
{
|
||||
$response = new \think\response\View();
|
||||
return $response->data($template)->vars($vars)->code($code);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user