From 5ed52b98a1e1b7d0f09949274f454d2de513f496 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sat, 15 Jun 2013 14:10:47 +0200 Subject: [PATCH 1/2] renamed Application::handle() to handelRequest() Name make more sense imo as it is not clear what it handles otherwise. Removed unused method processRequest form console app and also refactored console Application to be more similar to web Application. --- framework/yii/base/Application.php | 4 ++-- framework/yii/console/Application.php | 25 ++++++------------------- framework/yii/web/Application.php | 3 +-- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/framework/yii/base/Application.php b/framework/yii/base/Application.php index b1a7750..9eeb53b 100644 --- a/framework/yii/base/Application.php +++ b/framework/yii/base/Application.php @@ -139,7 +139,7 @@ abstract class Application extends Module */ public function run() { - $response = $this->handle($this->getRequest()); + $response = $this->handleRequest($this->getRequest()); $response->send(); return $response->exitStatus; } @@ -153,7 +153,7 @@ abstract class Application extends Module * @param Request $request the request to be handled * @return Response the resulting response */ - abstract public function handle($request); + abstract public function handleRequest($request); private $_runtimePath; diff --git a/framework/yii/console/Application.php b/framework/yii/console/Application.php index 6c3617e..b1b12b0 100644 --- a/framework/yii/console/Application.php +++ b/framework/yii/console/Application.php @@ -88,9 +88,14 @@ class Application extends \yii\base\Application * Handles the specified request. * @param Request $request the request to be handled * @return Response the resulting response + * @throws Exception when script is not running on command line. + * @throws Exception if the route is invalid */ - public function handle($request) + public function handleRequest($request) { + if (!$request->getIsConsoleRequest()) { + throw new Exception(\Yii::t('yii', 'This script must be run from the command line.')); + } list ($route, $params) = $request->resolve(); $result = $this->runAction($route, $params); if ($result instanceof Response) { @@ -103,24 +108,6 @@ class Application extends \yii\base\Application } /** - * Processes the request. - * The request is represented in terms of a controller route and action parameters. - * @return integer the exit status of the controller action (0 means normal, non-zero values mean abnormal) - * @throws Exception if the script is not running from the command line - */ - public function processRequest() - { - /** @var $request Request */ - $request = $this->getRequest(); - if ($request->getIsConsoleRequest()) { - list ($route, $params) = $request->resolve(); - return $this->runAction($route, $params); - } else { - throw new Exception(\Yii::t('yii', 'This script must be run from the command line.')); - } - } - - /** * Returns the response component. * @return Response the response component */ diff --git a/framework/yii/web/Application.php b/framework/yii/web/Application.php index 5ac0e13..6536db7 100644 --- a/framework/yii/web/Application.php +++ b/framework/yii/web/Application.php @@ -53,7 +53,7 @@ class Application extends \yii\base\Application * @return Response the resulting response * @throws HttpException if the requested route is invalid */ - public function handle($request) + public function handleRequest($request) { Yii::setAlias('@wwwroot', dirname($request->getScriptFile())); Yii::setAlias('@www', $request->getBaseUrl()); @@ -78,7 +78,6 @@ class Application extends \yii\base\Application } catch (InvalidRouteException $e) { throw new HttpException(404, $e->getMessage(), $e->getCode(), $e); } - } private $_homeUrl; From 36184569a88360569d5050f9d25a96668bae30f9 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sat, 15 Jun 2013 14:20:50 +0200 Subject: [PATCH 2/2] removed unnecessary check --- framework/yii/console/Application.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/framework/yii/console/Application.php b/framework/yii/console/Application.php index b1b12b0..c5e22ab 100644 --- a/framework/yii/console/Application.php +++ b/framework/yii/console/Application.php @@ -88,14 +88,9 @@ class Application extends \yii\base\Application * Handles the specified request. * @param Request $request the request to be handled * @return Response the resulting response - * @throws Exception when script is not running on command line. - * @throws Exception if the route is invalid */ public function handleRequest($request) { - if (!$request->getIsConsoleRequest()) { - throw new Exception(\Yii::t('yii', 'This script must be run from the command line.')); - } list ($route, $params) = $request->resolve(); $result = $this->runAction($route, $params); if ($result instanceof Response) {