diff --git a/apps/basic/commands/HelloController.php b/apps/basic/commands/HelloController.php index 86ab8b8534..9314fe7fde 100644 --- a/apps/basic/commands/HelloController.php +++ b/apps/basic/commands/HelloController.php @@ -27,4 +27,20 @@ class HelloController extends Controller { echo $message . "\n"; } + + public function actionTest() + { + echo 'Test?'; + } + +// public function getDescription($actionID = null) +// { +// return "I'm custom description for $actionID!"; +// } + + + public function getHelp($actionID = null) + { + return "I'm custom help for $actionID!"; + } } diff --git a/build/controllers/PhpDocController.php b/build/controllers/PhpDocController.php index f085c51a71..c0b390c33c 100644 --- a/build/controllers/PhpDocController.php +++ b/build/controllers/PhpDocController.php @@ -103,9 +103,9 @@ class PhpDocController extends Controller /** * @inheritdoc */ - public function options($actionId) + public function options($actionID) { - return array_merge(parent::options($actionId), ['updateFiles']); + return array_merge(parent::options($actionID), ['updateFiles']); } protected function findFiles($root) diff --git a/extensions/apidoc/commands/ApiController.php b/extensions/apidoc/commands/ApiController.php index 17ce3fb76b..79e8380dec 100644 --- a/extensions/apidoc/commands/ApiController.php +++ b/extensions/apidoc/commands/ApiController.php @@ -159,8 +159,8 @@ class ApiController extends BaseController /** * @inheritdoc */ - public function options($actionId) + public function options($actionID) { - return array_merge(parent::options($actionId), ['template', 'guide']); + return array_merge(parent::options($actionID), ['template', 'guide']); } } diff --git a/extensions/apidoc/commands/GuideController.php b/extensions/apidoc/commands/GuideController.php index c4f7495bd8..9d3ca6925d 100644 --- a/extensions/apidoc/commands/GuideController.php +++ b/extensions/apidoc/commands/GuideController.php @@ -113,8 +113,8 @@ class GuideController extends BaseController /** * @inheritdoc */ - public function options($actionId) + public function options($actionID) { - return array_merge(parent::options($actionId), ['apiDocs']); + return array_merge(parent::options($actionID), ['apiDocs']); } } diff --git a/extensions/apidoc/components/BaseController.php b/extensions/apidoc/components/BaseController.php index 83521a1317..257b1fef44 100644 --- a/extensions/apidoc/components/BaseController.php +++ b/extensions/apidoc/components/BaseController.php @@ -127,8 +127,8 @@ abstract class BaseController extends Controller /** * @inheritdoc */ - public function options($actionId) + public function options($actionID) { - return array_merge(parent::options($actionId), ['template', 'exclude']); + return array_merge(parent::options($actionID), ['template', 'exclude']); } } diff --git a/extensions/faker/FixtureController.php b/extensions/faker/FixtureController.php index 0dfe41c32d..6846362295 100644 --- a/extensions/faker/FixtureController.php +++ b/extensions/faker/FixtureController.php @@ -168,9 +168,9 @@ class FixtureController extends \yii\console\controllers\FixtureController /** * @inheritdoc */ - public function options($actionId) + public function options($actionID) { - return array_merge(parent::options($actionId), [ + return array_merge(parent::options($actionID), [ 'templatePath', 'language', 'fixtureDataPath' ]); } diff --git a/extensions/mongodb/console/controllers/MigrateController.php b/extensions/mongodb/console/controllers/MigrateController.php index e6b05a1611..c42ddc78b5 100644 --- a/extensions/mongodb/console/controllers/MigrateController.php +++ b/extensions/mongodb/console/controllers/MigrateController.php @@ -73,10 +73,10 @@ class MigrateController extends BaseMigrateController /** * @inheritdoc */ - public function options($actionId) + public function options($actionID) { return array_merge( - parent::options($actionId), + parent::options($actionID), ['migrationCollection', 'db'] // global for all actions ); } diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 88e59bc27a..2b299293f5 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -421,7 +421,7 @@ Yii Framework 2 Change Log - Enh #2526: Allow for null values in batchInsert (skotos) - Enh #2646: Added support for specifying hostinfo in the pattern of a URL rule (qiangxue) - Enh #2661: Added boolean column type support for SQLite (qiangxue) -- Enh #2670: Changed `console\Controller::globalOptions()` to `options($actionId)` to (make it possible to) differentiate options per action (hqx) +- Enh #2670: Changed `console\Controller::globalOptions()` to `options($actionID)` to (make it possible to) differentiate options per action (hqx) - Enh #2714: Added support for formatting time intervals relative to the current time with `yii\base\Formatter` (drenty) - Enh #2726: Added `yii\db\ActiveRecord::loadDefaultValues()` that fills default values from DB schema (samdark) - Enh #2729: Added `FilterValidator::skipOnArray` so that filters like `trim` will not fail for array inputs (qiangxue) diff --git a/framework/console/Controller.php b/framework/console/Controller.php index 3c21de697b..a4381a2b00 100644 --- a/framework/console/Controller.php +++ b/framework/console/Controller.php @@ -267,10 +267,10 @@ class Controller extends \yii\base\Controller * Note that the values setting via options are not available * until [[beforeAction()]] is being called. * - * @param string $actionId the action id of the current request + * @param string $actionID the action id of the current request * @return array the names of the options valid for the action */ - public function options($actionId) + public function options($actionID) { // $id might be used in subclass to provide options specific to action id return ['color', 'interactive']; diff --git a/framework/console/controllers/BaseMigrateController.php b/framework/console/controllers/BaseMigrateController.php index 9737012a23..ab7c298369 100644 --- a/framework/console/controllers/BaseMigrateController.php +++ b/framework/console/controllers/BaseMigrateController.php @@ -45,12 +45,12 @@ abstract class BaseMigrateController extends Controller /** * @inheritdoc */ - public function options($actionId) + public function options($actionID) { return array_merge( - parent::options($actionId), + parent::options($actionID), ['migrationPath'], // global for all actions - ($actionId == 'create') ? ['templateFile'] : [] // action create + ($actionID == 'create') ? ['templateFile'] : [] // action create ); } diff --git a/framework/console/controllers/FixtureController.php b/framework/console/controllers/FixtureController.php index 181f00ded8..4919a11b95 100644 --- a/framework/console/controllers/FixtureController.php +++ b/framework/console/controllers/FixtureController.php @@ -71,9 +71,9 @@ class FixtureController extends Controller /** * @inheritdoc */ - public function options($actionId) + public function options($actionID) { - return array_merge(parent::options($actionId), [ + return array_merge(parent::options($actionID), [ 'namespace', 'globalFixtures', 'append' ]); } diff --git a/framework/console/controllers/MigrateController.php b/framework/console/controllers/MigrateController.php index 464e707ea5..826bc580fa 100644 --- a/framework/console/controllers/MigrateController.php +++ b/framework/console/controllers/MigrateController.php @@ -72,10 +72,10 @@ class MigrateController extends BaseMigrateController /** * @inheritdoc */ - public function options($actionId) + public function options($actionID) { return array_merge( - parent::options($actionId), + parent::options($actionID), ['migrationTable', 'db'] // global for all actions ); } diff --git a/tests/unit/framework/console/controllers/AssetControllerTest.php b/tests/unit/framework/console/controllers/AssetControllerTest.php index 1041135465..6f476cc033 100644 --- a/tests/unit/framework/console/controllers/AssetControllerTest.php +++ b/tests/unit/framework/console/controllers/AssetControllerTest.php @@ -77,16 +77,16 @@ class AssetControllerTest extends TestCase /** * Emulates running of the asset controller action. - * @param string $actionId id of action to be run. + * @param string $actionID id of action to be run. * @param array $args action arguments. * @return string command output. */ - protected function runAssetControllerAction($actionId, array $args = []) + protected function runAssetControllerAction($actionID, array $args = []) { $controller = $this->createAssetController(); ob_start(); ob_implicit_flush(false); - $controller->run($actionId, $args); + $controller->run($actionID, $args); return ob_get_clean(); } diff --git a/tests/unit/framework/console/controllers/BaseMessageControllerTest.php b/tests/unit/framework/console/controllers/BaseMessageControllerTest.php index 3701704290..0295d4037f 100644 --- a/tests/unit/framework/console/controllers/BaseMessageControllerTest.php +++ b/tests/unit/framework/console/controllers/BaseMessageControllerTest.php @@ -51,16 +51,16 @@ abstract class BaseMessageControllerTest extends TestCase /** * Emulates running of the message controller action. - * @param string $actionId id of action to be run. + * @param string $actionID id of action to be run. * @param array $args action arguments. * @return string command output. */ - protected function runMessageControllerAction($actionId, array $args = []) + protected function runMessageControllerAction($actionID, array $args = []) { $controller = $this->createMessageController(); ob_start(); ob_implicit_flush(false); - $controller->run($actionId, $args); + $controller->run($actionID, $args); return ob_get_clean(); } diff --git a/tests/unit/framework/console/controllers/MigrateControllerTestTrait.php b/tests/unit/framework/console/controllers/MigrateControllerTestTrait.php index d80919e98a..8d5f82f9c1 100644 --- a/tests/unit/framework/console/controllers/MigrateControllerTestTrait.php +++ b/tests/unit/framework/console/controllers/MigrateControllerTestTrait.php @@ -63,16 +63,16 @@ trait MigrateControllerTestTrait /** * Emulates running of the migrate controller action. - * @param string $actionId id of action to be run. + * @param string $actionID id of action to be run. * @param array $args action arguments. * @return string command output. */ - protected function runMigrateControllerAction($actionId, array $args = []) + protected function runMigrateControllerAction($actionID, array $args = []) { $controller = $this->createMigrateController(); ob_start(); ob_implicit_flush(false); - $controller->run($actionId, $args); + $controller->run($actionID, $args); return ob_get_clean(); } diff --git a/tests/unit/framework/helpers/UrlTest.php b/tests/unit/framework/helpers/UrlTest.php index 32c4c5a3d0..610c1dd696 100644 --- a/tests/unit/framework/helpers/UrlTest.php +++ b/tests/unit/framework/helpers/UrlTest.php @@ -38,15 +38,15 @@ class UrlTest extends TestCase * Mocks controller action with parameters * * @param string $controllerId - * @param string $actionId + * @param string $actionID * @param string $moduleID * @param array $params */ - protected function mockAction($controllerId, $actionId, $moduleID = null, $params = []) + protected function mockAction($controllerId, $actionID, $moduleID = null, $params = []) { \Yii::$app->controller = $controller = new Controller($controllerId, \Yii::$app); $controller->actionParams = $params; - $controller->action = new Action($actionId, $controller); + $controller->action = new Action($actionID, $controller); if ($moduleID !== null) { $controller->module = new Module($moduleID);