From 126bb348ca90efc11bb94982721043c6fa400219 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 13 Jun 2016 16:54:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BResponse=E7=B1=BB=E7=9A=84sen?= =?UTF-8?q?d=E6=96=B9=E6=B3=95=E5=92=8CgetContent=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Response.php | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/library/think/Response.php b/library/think/Response.php index 0024e0af..be92774d 100644 --- a/library/think/Response.php +++ b/library/think/Response.php @@ -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); } /**