File tree 3 files changed +7
-9
lines changed
3 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -58,9 +58,8 @@ class CreateAction extends JsonApiAction
58
58
* It must return a string representing the scenario to be assigned to the model before it is validated and saved.
59
59
* The signature of the callable should be as follows,
60
60
* ```php
61
- * function ($action, $model = null ) {
61
+ * function ($action, $model) {
62
62
* // $model is the requested model instance.
63
- * // If null, it means no specific model (e.g. CreateAction)
64
63
* }
65
64
* ```
66
65
*/
@@ -110,9 +109,10 @@ public function run()
110
109
}
111
110
112
111
/* @var $model \yii\db\ActiveRecord */
113
- $ model = new $ this ->modelClass ([
114
- 'scenario ' => is_callable ($ this ->scenario ) ? call_user_func ($ this ->scenario , $ this ->id ) : $ this ->scenario ,
115
- ]);
112
+ $ model = new $ this ->modelClass ();
113
+ $ model ->setScenario (is_callable ($ this ->scenario ) ?
114
+ call_user_func ($ this ->scenario , $ this ->id , $ model ) : $ this ->scenario
115
+ );
116
116
RelationshipManager::validateRelationships ($ model , $ this ->getResourceRelationships (), $ this ->allowedRelations );
117
117
$ model ->load ($ this ->getResourceAttributes (), '' );
118
118
if ($ this ->isParentRestrictionRequired ()) {
Original file line number Diff line number Diff line change @@ -29,9 +29,8 @@ class DeleteAction extends JsonApiAction
29
29
* It must return a string representing the scenario to be assigned to the model before it is validated and saved.
30
30
* The signature of the callable should be as follows,
31
31
* ```php
32
- * function ($action, $model = null ) {
32
+ * function ($action, $model) {
33
33
* // $model is the requested model instance.
34
- * // If null, it means no specific model (e.g. CreateAction)
35
34
* }
36
35
* ```
37
36
*/
Original file line number Diff line number Diff line change @@ -59,9 +59,8 @@ class UpdateAction extends JsonApiAction
59
59
* It must return a string representing the scenario to be assigned to the model before it is validated and updated.
60
60
* The signature of the callable should be as follows,
61
61
* ```php
62
- * function ($action, $model = null ) {
62
+ * function ($action, $model) {
63
63
* // $model is the requested model instance.
64
- * // If null, it means no specific model (e.g. CreateAction)
65
64
* }
66
65
* ```
67
66
*/
You can’t perform that action at this time.
0 commit comments