From d74e89a1ca43d9684114b137ea7fb922c6d0e1b4 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 4 Sep 2014 01:26:42 +0400 Subject: [PATCH] Extracted inline action object creation, implemented it in console controller in order to use console inline action instead of base one --- framework/base/Controller.php | 14 +++++++++++++- framework/console/Controller.php | 10 +++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/framework/base/Controller.php b/framework/base/Controller.php index 072984be37..afa29459d0 100644 --- a/framework/base/Controller.php +++ b/framework/base/Controller.php @@ -220,7 +220,7 @@ class Controller extends Component implements ViewContextInterface if (method_exists($this, $methodName)) { $method = new \ReflectionMethod($this, $methodName); if ($method->isPublic() && $method->getName() === $methodName) { - return new InlineAction($id, $this, $methodName); + return $this->createActionObject($id, $methodName); } } } @@ -228,6 +228,18 @@ class Controller extends Component implements ViewContextInterface return null; } + /** + * Creates action object instance + * + * @param string $id the ID of this action + * @param string $methodName the controller method that action is associated with + * @return \yii\base\InlineAction + */ + protected function createActionObject($id, $methodName) + { + return new InlineAction($id, $this, $methodName); + } + /** * This method is invoked right before an action is executed. * diff --git a/framework/console/Controller.php b/framework/console/Controller.php index e71ad3ab70..92c16b8e92 100644 --- a/framework/console/Controller.php +++ b/framework/console/Controller.php @@ -9,7 +9,6 @@ namespace yii\console; use Yii; use yii\base\Action; -use yii\base\InlineAction; use yii\base\InvalidRouteException; use yii\helpers\Console; @@ -60,6 +59,15 @@ class Controller extends \yii\base\Controller return $this->color === null ? Console::streamSupportsAnsiColors($stream) : $this->color; } + /** + * @inheritdoc + * @return \yii\console\InlineAction + */ + protected function createActionObject($id, $methodName) + { + return new InlineAction($id, $this, $methodName); + } + /** * Runs an action with the specified action ID and parameters. * If the action ID is empty, the method will use [[defaultAction]].