Skip to content

Commit dca12a0

Browse files
committed
Resolve TODO
1 parent e20e74a commit dca12a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1020
-11
lines changed

Diff for: TODO.taskpaper

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ TODO.taskpaper
22

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)
5-
implement default action `actionIndex()` in `DefaultController` in module generation
5+
implement default action `actionIndex()` in `DefaultController` in module generation @done (25-04-09 15:44)
66
✔ 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

Diff for: tests/specs/issue_fix/controller_namespace_issue_for_modules_in_urlprefixes/index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
],
1010
'generateControllers' => true,
1111
'generateMigrations' => false,
12-
'useJsonApi' => true, # TODO run same tests with `false`
12+
'useJsonApi' => true,
1313
'urlPrefixes' => [
1414
'animals' => '',
1515
'/info' => ['module' =>'petinfo','namespace' => '\app\modules\petinfo\controllers'],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
* OpenAPI UrlRules
4+
*
5+
* This file is auto generated.
6+
*/
7+
return [
8+
'GET api/v1/pets' => 'api/v1/pet/list',
9+
'POST api/v1/pets' => 'api/v1/pet/create',
10+
'GET animals/pets/<id:[\w-]+>' => 'pet/view',
11+
'DELETE animals/pets/<id:[\w-]+>' => 'pet/delete',
12+
'PATCH animals/pets/<id:[\w-]+>' => 'pet/update',
13+
'GET petComments' => 'pet-comment/list',
14+
'GET info/pet-details' => 'petinfo/pet-detail/list',
15+
'GET fgh/pet-detail2s' => 'fgh/pet-detail2/list',
16+
'GET fgh2/pet-detail2s' => 'fgh2/pet-detail2/list',
17+
'GET theprefix/ctrl' => 'themodule/ctrl/list',
18+
'api/v1/pets' => 'api/v1/pet/options',
19+
'animals/pets/<id:[\w-]+>' => 'pet/options',
20+
'petComments' => 'pet-comment/options',
21+
'info/pet-details' => 'petinfo/pet-detail/options',
22+
'fgh/pet-detail2s' => 'fgh/pet-detail2/options',
23+
'fgh2/pet-detail2s' => 'fgh2/pet-detail2/options',
24+
'theprefix/ctrl' => 'themodule/ctrl/options',
25+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace app\controllers;
4+
5+
class PetCommentController extends \app\controllers\base\PetCommentController
6+
{
7+
8+
public function actions()
9+
{
10+
$actions = parent::actions();
11+
return $actions;
12+
}
13+
14+
public function checkAccess($action, $model = null, $params = [])
15+
{
16+
//TODO implement checkAccess
17+
}
18+
19+
public function actionList()
20+
{
21+
//TODO implement actionList
22+
}
23+
24+
25+
}
26+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace app\controllers;
4+
5+
class PetController extends \app\controllers\base\PetController
6+
{
7+
8+
public function actions()
9+
{
10+
$actions = parent::actions();
11+
return $actions;
12+
}
13+
14+
public function checkAccess($action, $model = null, $params = [])
15+
{
16+
//TODO implement checkAccess
17+
}
18+
19+
20+
}
21+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
namespace app\controllers\base;
3+
4+
use insolita\fractal\JsonApiController;
5+
use Yii;
6+
7+
abstract class PetCommentController extends JsonApiController
8+
{
9+
public function actions()
10+
{
11+
return [
12+
'options' => [
13+
'class' => \yii\rest\OptionsAction::class,
14+
],
15+
];
16+
}
17+
18+
/**
19+
* Checks the privilege of the current user.
20+
*
21+
* This method checks whether the current user has the privilege
22+
* to run the specified action against the specified data model.
23+
* If the user does not have access, a [[ForbiddenHttpException]] should be thrown.
24+
*
25+
* @param string $action the ID of the action to be executed
26+
* @param object $model the model to be accessed. If null, it means no specific model is being accessed.
27+
* @param array $params additional parameters
28+
* @throws \yii\web\ForbiddenHttpException if the user does not have access
29+
*/
30+
abstract public function checkAccess($action, $model = null, $params = []);
31+
32+
abstract public function actionList();
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
namespace app\controllers\base;
3+
4+
use insolita\fractal\JsonApiController;
5+
use Yii;
6+
7+
abstract class PetController extends JsonApiController
8+
{
9+
public function actions()
10+
{
11+
return [
12+
'view' => [
13+
'class' => \insolita\fractal\actions\ViewAction::class,
14+
'checkAccess' => [$this, 'checkAccess'],
15+
'transformer' => \app\transformers\PetTransformer::class,
16+
'modelClass' => \app\models\Pet::class,
17+
'resourceKey' => 'pets',
18+
'findModel' => null
19+
],
20+
'delete' => [
21+
'class' => \insolita\fractal\actions\DeleteAction::class,
22+
'checkAccess' => [$this, 'checkAccess'],
23+
'modelClass' => \app\models\Pet::class,
24+
'findModel' => null
25+
],
26+
'update' => [
27+
'class' => \insolita\fractal\actions\UpdateAction::class,
28+
'checkAccess' => [$this, 'checkAccess'],
29+
'transformer' => \app\transformers\PetTransformer::class,
30+
'modelClass' => \app\models\Pet::class,
31+
'resourceKey' => 'pets',
32+
'findModel' => null,
33+
'allowedRelations'=>[],
34+
'scenario' => 'default'
35+
],
36+
'options' => [
37+
'class' => \yii\rest\OptionsAction::class,
38+
],
39+
];
40+
}
41+
42+
/**
43+
* Checks the privilege of the current user.
44+
*
45+
* This method checks whether the current user has the privilege
46+
* to run the specified action against the specified data model.
47+
* If the user does not have access, a [[ForbiddenHttpException]] should be thrown.
48+
*
49+
* @param string $action the ID of the action to be executed
50+
* @param object $model the model to be accessed. If null, it means no specific model is being accessed.
51+
* @param array $params additional parameters
52+
* @throws \yii\web\ForbiddenHttpException if the user does not have access
53+
*/
54+
abstract public function checkAccess($action, $model = null, $params = []);
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace app\api\v1\controllers;
4+
5+
class PetController extends \app\api\v1\controllers\base\PetController
6+
{
7+
8+
public function actions()
9+
{
10+
$actions = parent::actions();
11+
return $actions;
12+
}
13+
14+
public function checkAccess($action, $model = null, $params = [])
15+
{
16+
//TODO implement checkAccess
17+
}
18+
19+
20+
}
21+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
namespace app\api\v1\controllers\base;
3+
4+
use insolita\fractal\JsonApiController;
5+
use Yii;
6+
7+
abstract class PetController extends JsonApiController
8+
{
9+
public function actions()
10+
{
11+
return [
12+
'list' => [
13+
'class' => \insolita\fractal\actions\ListAction::class,
14+
'checkAccess' => [$this, 'checkAccess'],
15+
'transformer' => \app\transformers\PetTransformer::class,
16+
'modelClass' => \app\models\Pet::class,
17+
'resourceKey' => 'pets',
18+
'dataFilter' => null,
19+
'prepareDataProvider' => null
20+
],
21+
'create' => [
22+
'class' => \insolita\fractal\actions\CreateAction::class,
23+
'checkAccess' => [$this, 'checkAccess'],
24+
'transformer' => \app\transformers\PetTransformer::class,
25+
'modelClass' => \app\models\Pet::class,
26+
'resourceKey' => 'pets',
27+
'allowedRelations'=>[],
28+
'viewRoute' => 'view',
29+
'scenario' => 'default'
30+
],
31+
'options' => [
32+
'class' => \yii\rest\OptionsAction::class,
33+
],
34+
];
35+
}
36+
37+
/**
38+
* Checks the privilege of the current user.
39+
*
40+
* This method checks whether the current user has the privilege
41+
* to run the specified action against the specified data model.
42+
* If the user does not have access, a [[ForbiddenHttpException]] should be thrown.
43+
*
44+
* @param string $action the ID of the action to be executed
45+
* @param object $model the model to be accessed. If null, it means no specific model is being accessed.
46+
* @param array $params additional parameters
47+
* @throws \yii\web\ForbiddenHttpException if the user does not have access
48+
*/
49+
abstract public function checkAccess($action, $model = null, $params = []);
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace app\modules\fgh\controllers;
4+
5+
class PetDetail2Controller extends \app\modules\fgh\controllers\base\PetDetail2Controller
6+
{
7+
8+
public function actions()
9+
{
10+
$actions = parent::actions();
11+
return $actions;
12+
}
13+
14+
public function checkAccess($action, $model = null, $params = [])
15+
{
16+
//TODO implement checkAccess
17+
}
18+
19+
public function actionList()
20+
{
21+
//TODO implement actionList
22+
}
23+
24+
25+
}
26+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
namespace app\modules\fgh\controllers\base;
3+
4+
use insolita\fractal\JsonApiController;
5+
use Yii;
6+
7+
abstract class PetDetail2Controller extends JsonApiController
8+
{
9+
public function actions()
10+
{
11+
return [
12+
'options' => [
13+
'class' => \yii\rest\OptionsAction::class,
14+
],
15+
];
16+
}
17+
18+
/**
19+
* Checks the privilege of the current user.
20+
*
21+
* This method checks whether the current user has the privilege
22+
* to run the specified action against the specified data model.
23+
* If the user does not have access, a [[ForbiddenHttpException]] should be thrown.
24+
*
25+
* @param string $action the ID of the action to be executed
26+
* @param object $model the model to be accessed. If null, it means no specific model is being accessed.
27+
* @param array $params additional parameters
28+
* @throws \yii\web\ForbiddenHttpException if the user does not have access
29+
*/
30+
abstract public function checkAccess($action, $model = null, $params = []);
31+
32+
abstract public function actionList();
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace app\fgh2\controllers;
4+
5+
class PetDetail2Controller extends \app\fgh2\controllers\base\PetDetail2Controller
6+
{
7+
8+
public function actions()
9+
{
10+
$actions = parent::actions();
11+
return $actions;
12+
}
13+
14+
public function checkAccess($action, $model = null, $params = [])
15+
{
16+
//TODO implement checkAccess
17+
}
18+
19+
public function actionList()
20+
{
21+
//TODO implement actionList
22+
}
23+
24+
25+
}
26+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
namespace app\fgh2\controllers\base;
3+
4+
use insolita\fractal\JsonApiController;
5+
use Yii;
6+
7+
abstract class PetDetail2Controller extends JsonApiController
8+
{
9+
public function actions()
10+
{
11+
return [
12+
'options' => [
13+
'class' => \yii\rest\OptionsAction::class,
14+
],
15+
];
16+
}
17+
18+
/**
19+
* Checks the privilege of the current user.
20+
*
21+
* This method checks whether the current user has the privilege
22+
* to run the specified action against the specified data model.
23+
* If the user does not have access, a [[ForbiddenHttpException]] should be thrown.
24+
*
25+
* @param string $action the ID of the action to be executed
26+
* @param object $model the model to be accessed. If null, it means no specific model is being accessed.
27+
* @param array $params additional parameters
28+
* @throws \yii\web\ForbiddenHttpException if the user does not have access
29+
*/
30+
abstract public function checkAccess($action, $model = null, $params = []);
31+
32+
abstract public function actionList();
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace \app\modules\petinfo;
4+
5+
class Module extends \yii\base\Module
6+
{
7+
8+
public function init()
9+
{
10+
parent::init();
11+
}
12+
13+
14+
}
15+

0 commit comments

Comments
 (0)