Commit 277d8cba by Alexander Makarov

Got rid of console inline action

parent dbac35b1
...@@ -220,7 +220,7 @@ class Controller extends Component implements ViewContextInterface ...@@ -220,7 +220,7 @@ class Controller extends Component implements ViewContextInterface
if (method_exists($this, $methodName)) { if (method_exists($this, $methodName)) {
$method = new \ReflectionMethod($this, $methodName); $method = new \ReflectionMethod($this, $methodName);
if ($method->isPublic() && $method->getName() === $methodName) { if ($method->isPublic() && $method->getName() === $methodName) {
return $this->createActionObject($id, $methodName); return new InlineAction($id, $this, $methodName);
} }
} }
} }
...@@ -229,18 +229,6 @@ class Controller extends Component implements ViewContextInterface ...@@ -229,18 +229,6 @@ class Controller extends Component implements ViewContextInterface
} }
/** /**
* 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. * This method is invoked right before an action is executed.
* *
* The method will trigger the [[EVENT_BEFORE_ACTION]] event. The return value of the method * The method will trigger the [[EVENT_BEFORE_ACTION]] event. The return value of the method
......
...@@ -60,15 +60,6 @@ class Controller extends \yii\base\Controller ...@@ -60,15 +60,6 @@ class Controller extends \yii\base\Controller
} }
/** /**
* @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. * Runs an action with the specified action ID and parameters.
* If the action ID is empty, the method will use [[defaultAction]]. * If the action ID is empty, the method will use [[defaultAction]].
* @param string $id the ID of the action to be executed. * @param string $id the ID of the action to be executed.
...@@ -108,7 +99,7 @@ class Controller extends \yii\base\Controller ...@@ -108,7 +99,7 @@ class Controller extends \yii\base\Controller
*/ */
public function bindActionParams($action, $params) public function bindActionParams($action, $params)
{ {
if ($action instanceof InlineAction) { if ($action instanceof \yii\base\InlineAction) {
$method = new \ReflectionMethod($this, $action->actionMethod); $method = new \ReflectionMethod($this, $action->actionMethod);
} else { } else {
$method = new \ReflectionMethod($action, 'run'); $method = new \ReflectionMethod($action, 'run');
...@@ -303,7 +294,7 @@ class Controller extends \yii\base\Controller ...@@ -303,7 +294,7 @@ class Controller extends \yii\base\Controller
$class = new \ReflectionClass($action); $class = new \ReflectionClass($action);
} }
if ($action instanceof InlineAction) { if ($action instanceof \yii\base\InlineAction) {
$class = new \ReflectionMethod($this, $action->actionMethod); $class = new \ReflectionMethod($this, $action->actionMethod);
} }
...@@ -332,7 +323,7 @@ class Controller extends \yii\base\Controller ...@@ -332,7 +323,7 @@ class Controller extends \yii\base\Controller
$class = new \ReflectionClass($this->createAction($actionID)); $class = new \ReflectionClass($this->createAction($actionID));
} }
if ($action instanceof InlineAction) { if ($action instanceof \yii\base\InlineAction) {
$class = new \ReflectionMethod($this, $action->actionMethod); $class = new \ReflectionMethod($this, $action->actionMethod);
} }
......
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\console;
use Yii;
use yii\helpers\Console;
/**
* InlineAction represents an action that is defined as a controller method.
*
* @inheritdoc
*
* @author Carsten Brandt <mail@cebe.cc>
* @since 2.0
*/
class InlineAction extends \yii\base\InlineAction
{
/**
* Returns a short description (one line) of information about the action.
*
* The default implementation returns help information retrieved from the PHPDoc comments.
*
* @return string
*/
public function getDescription()
{
return null;
}
/**
* Returns help information for the action.
*
* The default implementation returns help information retrieved from the PHPDoc comments.
* @return string
*/
public function getHelp()
{
return null;
}
}
...@@ -12,7 +12,6 @@ use yii\base\Application; ...@@ -12,7 +12,6 @@ use yii\base\Application;
use yii\console\Action; use yii\console\Action;
use yii\console\Controller; use yii\console\Controller;
use yii\console\Exception; use yii\console\Exception;
use yii\console\InlineAction;
use yii\helpers\Console; use yii\helpers\Console;
use yii\helpers\Inflector; use yii\helpers\Inflector;
...@@ -250,13 +249,14 @@ class HelpController extends Controller ...@@ -250,13 +249,14 @@ class HelpController extends Controller
*/ */
protected function getActionSummary($controller, $actionID) protected function getActionSummary($controller, $actionID)
{ {
$description = ''; $description = null;
$action = $controller->createAction($actionID); $action = $controller->createAction($actionID);
if ($action instanceof InlineAction || $action instanceof Action) {
if ($action instanceof Action) {
$description = $action->getDescription(); $description = $action->getDescription();
if ($description === null) { }
$description = $controller->getDescription($actionID); if ($description === null) {
} $description = $controller->getDescription($actionID);
} }
return $description; return $description;
} }
...@@ -275,16 +275,17 @@ class HelpController extends Controller ...@@ -275,16 +275,17 @@ class HelpController extends Controller
'command' => rtrim($controller->getUniqueId() . '/' . $actionID, '/'), 'command' => rtrim($controller->getUniqueId() . '/' . $actionID, '/'),
])); ]));
} }
if ($action instanceof InlineAction) { $description = null;
if ($action instanceof \yii\base\InlineAction) {
$method = new \ReflectionMethod($controller, $action->actionMethod); $method = new \ReflectionMethod($controller, $action->actionMethod);
} else { } else {
$description = $action->getHelp();
$method = new \ReflectionMethod($action, 'run'); $method = new \ReflectionMethod($action, 'run');
} }
$tags = $this->parseComment($method->getDocComment()); $tags = $this->parseComment($method->getDocComment());
$options = $this->getOptionHelps($controller, $actionID); $options = $this->getOptionHelps($controller, $actionID);
$description = $action->getHelp();
if ($description === null) { if ($description === null) {
$description = $controller->getHelp($actionID); $description = $controller->getHelp($actionID);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment