From 357d5c0e008c6eb31472641f395397780a9fce20 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 1 Jun 2016 21:19:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BRequest=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/App.php | 4 +--- library/think/Request.php | 13 ++++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/library/think/App.php b/library/think/App.php index 2efc4f68..e4ffba12 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -271,9 +271,7 @@ class App // 设置当前请求的模块、控制器、操作 $request = Request::instance(); - $request->module($module); - $request->controller($controller); - $request->action($actionName); + $request->module($module)->controller($controller)->action($actionName); // 监听module_init Hook::listen('module_init', $request); diff --git a/library/think/Request.php b/library/think/Request.php index 601edf47..8d9c95fe 100644 --- a/library/think/Request.php +++ b/library/think/Request.php @@ -203,7 +203,7 @@ class Request { if (!empty($domain)) { $this->domain = $domain; - return; + return $this; } elseif (!$this->domain) { $this->domain = $this->scheme() . '://' . $this->host(); } @@ -220,7 +220,7 @@ class Request { if (is_string($url) && !empty($url)) { $this->url = $url; - return; + return $this; } elseif (!$this->url) { if (IS_CLI) { $this->url = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : ''; @@ -247,7 +247,7 @@ class Request { if (is_string($url) && !empty($url)) { $this->baseUrl = $url; - return; + return $this; } elseif (!$this->baseUrl) { $str = $this->url(); $this->baseUrl = strpos($str, '?') ? strstr($str, '?', true) : $str; @@ -265,7 +265,7 @@ class Request { if (is_string($file) && !empty($file)) { $this->baseFile = $file; - return; + return $this; } elseif (!$this->baseFile) { $url = ''; if (!IS_CLI) { @@ -297,7 +297,7 @@ class Request { if (is_string($url) && !empty($url)) { $this->root = $url; - return; + return $this; } elseif (!$this->root) { $file = $this->baseFile(); if ($file && 0 !== strpos($this->url(), $file)) { @@ -922,6 +922,7 @@ class Request { if (!is_null($module)) { $this->module = $module; + return $this; } else { return $this->module ?: ''; } @@ -937,6 +938,7 @@ class Request { if (!is_null($controller)) { $this->controller = $controller; + return $this; } else { return $this->controller ?: ''; } @@ -952,6 +954,7 @@ class Request { if (!is_null($action)) { $this->action = $action; + return $this; } else { return $this->action ?: ''; }