改进Response类 增加think\response\View类 用于渲染模板响应输出

This commit is contained in:
thinkphp
2016-05-16 18:10:46 +08:00
parent 4870d743ac
commit c7c94258d0
9 changed files with 92 additions and 143 deletions

View File

@@ -13,6 +13,8 @@ namespace think;
use think\exception\HttpResponseException;
use think\Response;
use think\response\Json;
use think\response\Jsonp;
/**
* App 应用管理
@@ -117,8 +119,20 @@ class App
// 监听app_end
APP_HOOK && Hook::listen('app_end', $data);
$type = IS_AJAX ? Config::get('default_ajax_return') : Config::get('default_return_type');
switch ($type) {
case 'json':
$response = new Json($data);
break;
case 'jsonp':
$response = new Jsonp($data);
break;
case 'html':
default:
$response = new Response($data, $type);
break;
}
// 自动响应输出
return Response::create($type)->send($data);
return $response->send();
}
}
}