File tree Expand file tree Collapse file tree 3 files changed +42
-6
lines changed Expand file tree Collapse file tree 3 files changed +42
-6
lines changed Original file line number Diff line number Diff line change @@ -38,10 +38,25 @@ class DeleteAction extends JsonApiAction
3838    public  $ scenarioSCENARIO_DEFAULT ;
3939
4040    /** 
41-      * @var callable|null a PHP callable that checks if deletion is allowed. 
41+      * @var callable|null A PHP callable that will be called to determine 
42+      * whether the deletion of a model is allowed. If not set, no deletion 
43+      * check will be performed. The callable should have the following signature: 
44+      * 
45+      * @example 
46+      * ```php 
47+      * function ($action, $model) { 
48+      *     // $model is the model instance being deleted. 
49+      * 
50+      *     // If the deletion is not allowed, an error should be thrown. For example: 
51+      *     if ($model->status !== 'draft') { 
52+      *         throw new MethodNotAllowedHttpException('The model can only be deleted if its status is "draft".'); 
53+      *     } 
54+      * } 
55+      * ``` 
4256     */ 
4357    public  $ checkDeleteAllowed
4458
59+ 
4560    /** 
4661     * @var callable|Closure Callback after save model with all relations 
4762     * @example 
Original file line number Diff line number Diff line change @@ -61,13 +61,20 @@ class JsonApiAction extends Action
6161    public  $ findModel
6262
6363    /** 
64-      * @var callable a PHP callable that will be called when running an action to determine 
65-      * if the current user has the permission to execute the action. If not set, the access 
66-      * check will not be performed. The signature of the callable should be as follows, 
64+      * @var callable A PHP callable that will be called when running an action to determine 
65+      * whether the current user has permission to execute the action. If not set, no access 
66+      * check will be performed. The callable should have the following signature: 
67+      * 
68+      * @example 
6769     * ```php 
6870     * function ($action, $model = null) { 
6971     *     // $model is the requested model instance. 
70-      *     // If null, it means no specific model (e.g. IndexAction) 
72+      *     // If null, it indicates no specific model (e.g., IndexAction). 
73+      * 
74+      *     // If the user does not have the required permissions, an error should be thrown. For example: 
75+      *     if (!Yii::$app->user->can('admin')) { 
76+      *         throw new ForbiddenHttpException(); 
77+      *     } 
7178     * } 
7279     * ``` 
7380     */ 
Original file line number Diff line number Diff line change @@ -68,7 +68,21 @@ class UpdateAction extends JsonApiAction
6868    public  $ scenarioSCENARIO_DEFAULT ;
6969
7070    /** 
71-      * @var callable|null a PHP callable that checks if updating is allowed. 
71+      * @var callable|null A PHP callable that will be called to determine 
72+      * whether the update of a model is allowed. If not set, no update 
73+      * check will be performed. The callable should have the following signature: 
74+      * 
75+      * @example 
76+      * ```php 
77+      * function ($action, $model) { 
78+      *     // $model is the model instance being updated. 
79+      * 
80+      *     // If the update is not allowed, an error should be thrown. For example: 
81+      *     if ($model->status === 'archived') { 
82+      *         throw new MethodNotAllowedHttpException('The model cannot be updated when its status is "archived".'); 
83+      *     } 
84+      * } 
85+      * ``` 
7286     */ 
7387    public  $ checkUpdateAllowed
7488
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments