@@ -23,19 +23,26 @@ class AdminDefaultController extends BaseController
23
23
public $ modelSearchClass ;
24
24
25
25
/**
26
- * If false then 'index', 'update', 'grid-sort', etc. will be disabled
26
+ * Actions that will be disabled
27
27
*
28
- * @var bool
28
+ * List of available actions:
29
+ *
30
+ * ['index', 'view', 'create', 'update', 'delete', 'toggle-attribute',
31
+ * 'bulk-activate', 'bulk-deactivate', 'bulk-delete', 'grid-sort', 'grid-page-size']
32
+ *
33
+ * @var array
29
34
*/
30
- protected $ enableBaseActions = true ;
35
+ public $ disabledActions = [] ;
31
36
32
37
/**
33
- * Actions that will be disable on enableBaseActions = false;
38
+ * Opposite to $disabledActions. Every action except those will be disabled
39
+ *
40
+ * But if action listed both in $disabledActions and $enableOnlyActions
41
+ * then it will be disabled
34
42
*
35
43
* @var array
36
44
*/
37
- protected $ baseActions = ['index ' , 'update ' , 'create ' , 'view ' , 'delete ' , 'toggleAttribute ' , 'bulkActivate ' ,
38
- 'bulkDeactivate ' , 'bulkDelete ' , 'gridSort ' , 'gridPageSize ' ];
45
+ public $ enableOnlyActions = [];
39
46
40
47
41
48
public function behaviors ()
@@ -301,7 +308,12 @@ public function beforeAction($action)
301
308
{
302
309
if ( parent ::beforeAction ($ action ) )
303
310
{
304
- if ( !$ this ->enableBaseActions AND in_array ($ action ->id , $ this ->baseActions ) )
311
+ if ( $ this ->enableOnlyActions !== [] AND !in_array ($ action ->id , $ this ->enableOnlyActions ) )
312
+ {
313
+ throw new NotFoundHttpException ('Page not found ' );
314
+ }
315
+
316
+ if ( in_array ($ action ->id , $ this ->disabledActions ) )
305
317
{
306
318
throw new NotFoundHttpException ('Page not found ' );
307
319
}
0 commit comments