Commit 277d8cba by Alexander Makarov

Got rid of console inline action

parent dbac35b1
......@@ -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 $this->createActionObject($id, $methodName);
return new InlineAction($id, $this, $methodName);
}
}
}
......@@ -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.
*
* 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
}
/**
* @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]].
* @param string $id the ID of the action to be executed.
......@@ -108,7 +99,7 @@ class Controller extends \yii\base\Controller
*/
public function bindActionParams($action, $params)
{
if ($action instanceof InlineAction) {
if ($action instanceof \yii\base\InlineAction) {
$method = new \ReflectionMethod($this, $action->actionMethod);
} else {
$method = new \ReflectionMethod($action, 'run');
......@@ -303,7 +294,7 @@ class Controller extends \yii\base\Controller
$class = new \ReflectionClass($action);
}
if ($action instanceof InlineAction) {
if ($action instanceof \yii\base\InlineAction) {
$class = new \ReflectionMethod($this, $action->actionMethod);
}
......@@ -332,7 +323,7 @@ class Controller extends \yii\base\Controller
$class = new \ReflectionClass($this->createAction($actionID));
}
if ($action instanceof InlineAction) {
if ($action instanceof \yii\base\InlineAction) {
$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;
use yii\console\Action;
use yii\console\Controller;
use yii\console\Exception;
use yii\console\InlineAction;
use yii\helpers\Console;
use yii\helpers\Inflector;
......@@ -250,13 +249,14 @@ class HelpController extends Controller
*/
protected function getActionSummary($controller, $actionID)
{
$description = '';
$description = null;
$action = $controller->createAction($actionID);
if ($action instanceof InlineAction || $action instanceof Action) {
if ($action instanceof Action) {
$description = $action->getDescription();
if ($description === null) {
$description = $controller->getDescription($actionID);
}
}
if ($description === null) {
$description = $controller->getDescription($actionID);
}
return $description;
}
......@@ -275,16 +275,17 @@ class HelpController extends Controller
'command' => rtrim($controller->getUniqueId() . '/' . $actionID, '/'),
]));
}
if ($action instanceof InlineAction) {
$description = null;
if ($action instanceof \yii\base\InlineAction) {
$method = new \ReflectionMethod($controller, $action->actionMethod);
} else {
$description = $action->getHelp();
$method = new \ReflectionMethod($action, 'run');
}
$tags = $this->parseComment($method->getDocComment());
$options = $this->getOptionHelps($controller, $actionID);
$description = $action->getHelp();
if ($description === null) {
$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