Skip to content

Commit 18c36c8

Browse files
committed
Support scenario for delete action
1 parent d7398fd commit 18c36c8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,7 @@
2929
- remove includes from counter actions
3030

3131
1.3.2
32-
- Add validator callback for ability to check allowedRelations for Create and Update Actions
32+
- Add validator callback for ability to check allowedRelations for Create and Update Actions
33+
34+
1.3.3
35+
- Add support scenario for delete action

src/actions/DeleteAction.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace insolita\fractal\actions;
99

1010
use Yii;
11+
use yii\base\Model;
1112
use yii\web\ForbiddenHttpException;
1213
use yii\web\ServerErrorHttpException;
1314

@@ -20,6 +21,11 @@ class DeleteAction extends JsonApiAction
2021
{
2122
use HasParentAttributes;
2223

24+
/**
25+
* @var string the scenario to be assigned to the new model before it is validated and saved.
26+
*/
27+
public $scenario = Model::SCENARIO_DEFAULT;
28+
2329
public function init():void
2430
{
2531
parent::init();
@@ -40,6 +46,7 @@ public function run($id):void
4046
throw new ForbiddenHttpException('Update with relationships not supported yet');
4147
}
4248
$model = $this->isParentRestrictionRequired() ? $this->findModelForParent($id) : $this->findModel($id);
49+
$model->setScenario($this->scenario);
4350
if ($this->checkAccess) {
4451
call_user_func($this->checkAccess, $this->id, $model);
4552
}

0 commit comments

Comments
 (0)