From 382e6a1f29bafb2e44c3872bcfe549829606e781 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 19 Jul 2016 11:29:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BRest=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/App.php | 3 +-- library/think/controller/Rest.php | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/library/think/App.php b/library/think/App.php index 9ff748df..ebc3a776 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -338,8 +338,7 @@ class App // 操作不存在 if (method_exists($instance, '_empty')) { $reflect = new \ReflectionMethod($instance, '_empty'); - $args = self::bindParams($reflect, Request::instance()->param()); - $data = $reflect->invokeArgs($instance, [$action, $args]); + $data = $reflect->invokeArgs($instance, [$action]); self::$debug && Log::record('[ RUN ] ' . $reflect->__toString(), 'info'); } else { throw new HttpException(404, 'method not exists:' . (new \ReflectionClass($instance))->getName() . '->' . $action); diff --git a/library/think/controller/Rest.php b/library/think/controller/Rest.php index a5288092..a75cfd37 100644 --- a/library/think/controller/Rest.php +++ b/library/think/controller/Rest.php @@ -11,6 +11,7 @@ namespace think\controller; +use think\App; use think\Request; use think\Response; @@ -61,11 +62,10 @@ abstract class Rest * REST 调用 * @access public * @param string $method 方法名 - * @param array $args 参数 * @return mixed * @throws \Exception */ - public function _empty($method, $args) + public function _empty($method) { if (method_exists($this, $method . '_' . $this->method . '_' . $this->type)) { // RESTFul方法支持 @@ -76,7 +76,7 @@ abstract class Rest $fun = $method . '_' . $this->method; } if (isset($fun)) { - return call_user_func_array([$this, $fun], $args); + return App::invokeMethod([$this, $fun]); } else { // 抛出异常 throw new \Exception('error action :' . $method);