Skip to content

Commit e2f42d5

Browse files
committed
revert
1 parent 8cbdbb2 commit e2f42d5

17 files changed

+19
-47
lines changed

CHANGELOG.md

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,4 @@
3535
- Add support scenario for delete action
3636

3737
1.3.4
38-
- Add aftersave callback for create/update actions that called after save model with all relations
39-
40-
2.0.0
41-
- Changed signature of checkAccess callbacks, now whole action object passed, instead of action id
42-
Before:
43-
```php
44-
...
45-
'checkAccess' => function(string $action, $model = null) {
46-
if($action === 'create') {
47-
//...
48-
}
49-
}
50-
```
51-
52-
After:
53-
Before:
54-
55-
```php
56-
57-
...
58-
'checkAccess' => function(JsonApiAction $action, $model = null) {
59-
if($action->id === 'create') {
60-
//...
61-
}
62-
63-
}
64-
```
38+
- Add aftersave callback for create/update actions that called after save model with all relations

src/ActiveJsonApiController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use insolita\fractal\actions\CreateAction;
1111
use insolita\fractal\actions\DeleteAction;
1212
use insolita\fractal\actions\HasResourceTransformer;
13-
use insolita\fractal\actions\JsonApiAction;
1413
use insolita\fractal\actions\ListAction;
1514
use insolita\fractal\actions\UpdateAction;
1615
use insolita\fractal\actions\ViewAction;
@@ -104,12 +103,12 @@ public function actions()
104103
* to run the specified action against the specified data model.
105104
* If the user does not have access, a [[ForbiddenHttpException]] should be thrown.
106105
*
107-
* @param \insolita\fractal\actions\JsonApiAction $action an instance of executed action
106+
* @param string $action the ID of the action to be executed
108107
* @param object $model the model to be accessed. If null, it means no specific model is being accessed.
109108
* @param array $params additional parameters
110109
* @throws ForbiddenHttpException if the user does not have access
111110
*/
112-
public function checkAccess(JsonApiAction $action, $model = null, $params = [])
111+
public function checkAccess($action, $model = null, $params = [])
113112
{
114113
}
115114
}

src/actions/CountAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function init():void
6969
public function run()
7070
{
7171
if ($this->checkAccess) {
72-
call_user_func($this->checkAccess, $this);
72+
call_user_func($this->checkAccess, $this->id);
7373
}
7474

7575
$query = $this->makeQuery();

src/actions/CountForIdentityAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class CountForIdentityAction extends JsonApiAction
5858
public function run()
5959
{
6060
if ($this->checkAccess) {
61-
call_user_func($this->checkAccess, $this);
61+
call_user_func($this->checkAccess, $this->id);
6262
}
6363

6464
$query = $this->makeQuery();

src/actions/CreateAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function init():void
9393
public function run()
9494
{
9595
if ($this->checkAccess) {
96-
call_user_func($this->checkAccess, $this);
96+
call_user_func($this->checkAccess, $this->id);
9797
}
9898

9999
/* @var $model \yii\db\ActiveRecord */

src/actions/CreateRelationshipAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function run($id)
7777
{
7878
$model = $this->findModel($id);
7979
if ($this->checkAccess) {
80-
call_user_func($this->checkAccess, $this, $model);
80+
call_user_func($this->checkAccess, $this->id, $model);
8181
}
8282
$manager = new RelationshipManager($model, $this->relationName, $this->getResourceData(), $this->pkType);
8383
if ($this->idValidateCallback !== null) {

src/actions/DeleteAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function run($id):void
4848
$model = $this->isParentRestrictionRequired() ? $this->findModelForParent($id) : $this->findModel($id);
4949
$model->setScenario($this->scenario);
5050
if ($this->checkAccess) {
51-
call_user_func($this->checkAccess, $this, $model);
51+
call_user_func($this->checkAccess, $this->id, $model);
5252
}
5353
if ($model->delete() === false) {
5454
throw new ServerErrorHttpException('Failed to delete the object for unknown reason.');

src/actions/DeleteRelationshipAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function run($id):void
6060
{
6161
$model = $this->findModel($id);
6262
if ($this->checkAccess) {
63-
call_user_func($this->checkAccess, $this, $model);
63+
call_user_func($this->checkAccess, $this->id, $model);
6464
}
6565
$manager = new RelationshipManager($model, $this->relationName, $this->getResourceData(), $this->pkType);
6666
if ($this->idValidateCallback !== null) {

src/actions/JsonApiAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class JsonApiAction extends Action
6565
* if the current user has the permission to execute the action. If not set, the access
6666
* check will not be performed. The signature of the callable should be as follows,
6767
* ```php
68-
* function (JsonApiAction $action, $model = null) {
68+
* function ($action, $model = null) {
6969
* // $model is the requested model instance.
7070
* // If null, it means no specific model (e.g. IndexAction)
7171
* }

src/actions/ListAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function init():void
7474
public function run()
7575
{
7676
if ($this->checkAccess) {
77-
call_user_func($this->checkAccess, $this);
77+
call_user_func($this->checkAccess, $this->id);
7878
}
7979

8080
$dataProvider = $this->makeDataProvider();

0 commit comments

Comments
 (0)