mirror of
https://github.com/yiisoft/yii2.git
synced 2025-12-01 15:07:49 +08:00
Extracted inline action object creation, implemented it in console controller in order to use console inline action instead of base one
This commit is contained in:
@@ -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 new InlineAction($id, $this, $methodName);
|
return $this->createActionObject($id, $methodName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,6 +228,18 @@ class Controller extends Component implements ViewContextInterface
|
|||||||
return null;
|
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.
|
* This method is invoked right before an action is executed.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ namespace yii\console;
|
|||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Action;
|
use yii\base\Action;
|
||||||
use yii\base\InlineAction;
|
|
||||||
use yii\base\InvalidRouteException;
|
use yii\base\InvalidRouteException;
|
||||||
use yii\helpers\Console;
|
use yii\helpers\Console;
|
||||||
|
|
||||||
@@ -60,6 +59,15 @@ class Controller extends \yii\base\Controller
|
|||||||
return $this->color === null ? Console::streamSupportsAnsiColors($stream) : $this->color;
|
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.
|
* 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]].
|
||||||
|
|||||||
Reference in New Issue
Block a user