Skip to content

Commit 89b5a6f

Browse files
committed
Complete another test
1 parent e08b802 commit 89b5a6f

File tree

16 files changed

+304
-14
lines changed

16 files changed

+304
-14
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace app\abc;
4+
5+
class Module extends \yii\base\Module
6+
{
7+
8+
public function init()
9+
{
10+
parent::init();
11+
}
12+
13+
14+
}
15+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace app\abc;
4+
5+
class TaskController extends \app\abc\base\TaskController
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+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
namespace app\abc\base;
3+
4+
use insolita\fractal\JsonApiController;
5+
use Yii;
6+
7+
abstract class TaskController 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\TaskTransformer::class,
16+
'modelClass' => \app\models\Task::class,
17+
'resourceKey' => 'tasks',
18+
'findModel' => null
19+
],
20+
'options' => [
21+
'class' => \yii\rest\OptionsAction::class,
22+
],
23+
];
24+
}
25+
26+
/**
27+
* Checks the privilege of the current user.
28+
*
29+
* This method checks whether the current user has the privilege
30+
* to run the specified action against the specified data model.
31+
* If the user does not have access, a [[ForbiddenHttpException]] should be thrown.
32+
*
33+
* @param string $action the ID of the action to be executed
34+
* @param object $model the model to be accessed. If null, it means no specific model is being accessed.
35+
* @param array $params additional parameters
36+
* @throws \yii\web\ForbiddenHttpException if the user does not have access
37+
*/
38+
abstract public function checkAccess($action, $model = null, $params = []);
39+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* OpenAPI UrlRules
4+
*
5+
* This file is auto generated.
6+
*/
7+
return [
8+
'GET hi' => 'greet/default',
9+
'GET bye' => 'bye/list',
10+
'POST bye' => 'bye/create',
11+
'GET abc/task/<id:\d+>' => 'abc/task/view',
12+
'hi' => 'greet/options',
13+
'bye' => 'bye/options',
14+
'abc/task/<id:\d+>' => 'abc/task/options',
15+
];
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace app\controllers;
4+
5+
class ByeController extends \app\controllers\base\ByeController
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+
public function actionCreate()
25+
{
26+
//TODO implement actionCreate
27+
}
28+
29+
30+
}
31+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
namespace app\controllers\base;
3+
4+
use insolita\fractal\JsonApiController;
5+
use Yii;
6+
7+
abstract class ByeController 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+
34+
abstract public function actionCreate();
35+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace app\greet;
4+
5+
class DefaultController extends \app\greet\base\DefaultController
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 action()
20+
{
21+
//TODO implement action
22+
}
23+
24+
25+
}
26+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace app\greet;
4+
5+
class Module extends \yii\base\Module
6+
{
7+
8+
public function init()
9+
{
10+
parent::init();
11+
}
12+
13+
14+
}
15+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
namespace app\greet\base;
3+
4+
use insolita\fractal\JsonApiController;
5+
use Yii;
6+
7+
abstract class DefaultController 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 action();
33+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace app\models;
4+
5+
class Task extends \app\models\base\Task
6+
{
7+
8+
9+
}
10+

0 commit comments

Comments
 (0)