Skip to content

Commit e20e74a

Browse files
committed
Implement default action actionIndex() in DefaultController in module generation
1 parent 89b5a6f commit e20e74a

File tree

6 files changed

+10
-7
lines changed

6 files changed

+10
-7
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ Generated URL rules config for above is (in `urls.rest.php` or pertinent file):
684684

685685
`x-route` must not start with slash `/`. For example `x-route: /user/posts` is incorrect. It must start with [module ID](https://www.yiiframework.com/doc/guide/2.0/en/structure-modules) or [controller ID](https://www.yiiframework.com/doc/guide/2.0/en/structure-controllers#controller-ids)
686686

687-
#### Route, path and namespace TODO
687+
#### Route, path and namespace
688688

689689
Route, path and namespace for controller/action will be resolved in following manner (from highest priority to lowest):
690690

TODO.taskpaper

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ TODO.taskpaper
33
✔ fix failing tests @done (25-03-21 16:20)
44
✔ Implement code generation for nested module in `x-route` and other pertinent place @done (25-03-26 11:38)
55
☐ implement default action `actionIndex()` in `DefaultController` in module generation
6-
resolve all sub tasks of issue - Support for Yii Modules in x-route and pertinent places #14
6+
resolve all sub tasks of issue - Support for Yii Modules in x-route and pertinent places #14 @done (25-04-09 08:50)
77
☐ resolve all TODOs
88
☐ delete this file

src/lib/generators/RestActionGenerator.php

+3
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ protected function prepareAction(
136136
$controllerId = $routeData->controller;
137137
}
138138
$action = Inflector::camel2id($routeData->action);
139+
if (!$action && !$actionType) {
140+
$action = 'index';
141+
}
139142
if (!empty($customRoute)) {
140143
$actionType = '';
141144
$parts = explode('/', $customRoute);

tests/specs/issue_fix/14_module_config_in_url_prefixes/mysql/config/urls.rest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* This file is auto generated.
66
*/
77
return [
8-
'GET hi' => 'greet/default',
8+
'GET hi' => 'greet/default/index',
99
'GET bye' => 'bye/list',
1010
'POST bye' => 'bye/create',
1111
'GET abc/task/<id:\d+>' => 'abc/task/view',
12-
'hi' => 'greet/options',
12+
'hi' => 'greet/default/options',
1313
'bye' => 'bye/options',
1414
'abc/task/<id:\d+>' => 'abc/task/options',
1515
];

tests/specs/issue_fix/14_module_config_in_url_prefixes/mysql/greet/DefaultController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ public function checkAccess($action, $model = null, $params = [])
1010
//TODO implement checkAccess
1111
}
1212

13-
public function action()
13+
public function actionIndex()
1414
{
15-
//TODO implement action
15+
//TODO implement actionIndex
1616
}
1717

1818

tests/specs/issue_fix/14_module_config_in_url_prefixes/mysql/greet/base/DefaultController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ public function actions()
2727
*/
2828
abstract public function checkAccess($action, $model = null, $params = []);
2929

30-
abstract public function action();
30+
abstract public function actionIndex();
3131

3232
}

0 commit comments

Comments
 (0)