Skip to content

Commit a496e79

Browse files
committed
revert
1 parent f090092 commit a496e79

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"yiisoft/yii2-gii": "~2.0.0 | ~2.1.0 | ~2.2.0",
2525
"fzaninotto/faker": "^1.8",
2626
"laminas/laminas-code": "^3.4",
27-
"insolita/yii2-fractal": "^2.0.0"
27+
"insolita/yii2-fractal": "^1.0.0"
2828
},
2929
"require-dev": {
3030
"cebe/indent": "*",

src/generator/default/controller_jsonapi.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
namespace <?= $namespace ?>;
1515

1616
use insolita\fractal\JsonApiController;
17-
use insolita\fractal\actions\JsonApiAction;
1817
use Yii;
1918

2019
abstract class <?= $className ?> extends JsonApiController
@@ -40,12 +39,12 @@ public function actions()
4039
* to run the specified action against the specified data model.
4140
* If the user does not have access, a [[ForbiddenHttpException]] should be thrown.
4241
*
43-
* @param JsonApiAction $action the ID of the action to be executed
42+
* @param string $action the ID of the action to be executed
4443
* @param object $model the model to be accessed. If null, it means no specific model is being accessed.
4544
* @param array $params additional parameters
4645
* @throws \yii\web\ForbiddenHttpException if the user does not have access
4746
*/
48-
abstract public function checkAccess(JsonApiAction $action, $model = null, $params = []);
47+
abstract public function checkAccess($action, $model = null, $params = []);
4948
<?php foreach ($actions as $action): ?>
5049
<?php if (!$action->shouldUseTemplate()):?>
5150
<?php if (!$action->shouldBeAbstract()):?>

src/lib/action_templates/deleteResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**@var \cebe\yii2openapi\lib\items\FractalAction $action */
33
?>
44
$model = $this-><?=$action->findModelMethodName?>($<?=$action->idParam?>);
5-
$this->checkAccess($action, $model);
5+
$this->checkAccess('<?=$action->id?>', $model);
66
if ($model->delete() === false) {
77
throw new \yii\web\ServerErrorHttpException('Failed to delete the object for unknown reason.');
88
}

src/lib/action_templates/updateResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
?>
44
$model = $this-><?=$action->findModelMethodName?>($<?=$action->idParam?>);
55
$model->scenario = 'default';
6-
$this->checkAccess($action, $model);
6+
$this->checkAccess('<?=$action->id?>', $model);
77
$model->load(Yii::$app->getRequest()->getBodyParams()['data']['attributes'] ?? [], '');
88
if ($model->save() === false && !$model->hasErrors()) {
99
throw new \yii\web\ServerErrorHttpException('Failed to update the object for unknown reason.');

src/lib/action_templates/viewResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
?>
55
$model = $this-><?=$action->findModelMethodName?>($<?=$action->idParam?>);
6-
$this->checkAccess($action, $model);
6+
$this->checkAccess('<?=$action->id?>', $model);
77
<?php if ($action->transformerFqn):?>
88
$transformer = Yii::createObject(['class'=>\<?=$action->transformerFqn?>::class]);
99
<?php else:?>

0 commit comments

Comments
 (0)