mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进Response类的send方法和getContent方法
This commit is contained in:
@@ -22,8 +22,6 @@ class Response
|
||||
protected $transform;
|
||||
// 原始数据
|
||||
protected $data;
|
||||
// 输出数据
|
||||
protected $content;
|
||||
// 输出类型
|
||||
protected $type;
|
||||
// 当前的contentType
|
||||
@@ -112,9 +110,7 @@ class Response
|
||||
defined('RESPONSE_TYPE') or define('RESPONSE_TYPE', $this->type);
|
||||
|
||||
// 处理输出数据
|
||||
$data = $this->getTransformData();
|
||||
// 输出数据赋值
|
||||
$this->content = $data;
|
||||
$data = $this->getContent();
|
||||
|
||||
// 监听response_data
|
||||
Hook::listen('response_data', $data, $this);
|
||||
@@ -144,22 +140,6 @@ class Response
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理数据
|
||||
* @access protected
|
||||
* @param mixed $data 要处理的数据
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getTransformData()
|
||||
{
|
||||
if (is_callable($this->transform)) {
|
||||
$data = call_user_func_array($this->transform, [$this->data]);
|
||||
}else{
|
||||
$data = $this->data;
|
||||
}
|
||||
return $this->output($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理数据
|
||||
* @access protected
|
||||
@@ -346,7 +326,12 @@ class Response
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content;
|
||||
if (is_callable($this->transform)) {
|
||||
$data = call_user_func_array($this->transform, [$this->data]);
|
||||
}else{
|
||||
$data = $this->data;
|
||||
}
|
||||
return $this->output($data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user