This repository was archived by the owner on Sep 19, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +23
-5
lines changed
Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Original file line number Diff line number Diff line change 1212class RouteAccessControl extends ActionFilter
1313{
1414/**
15- * @var array List of action that not need to check access.
15+ * List of action that not need to check access.
16+ *
17+ * @var array
1618 */
1719public $ allowActions = [];
1820
1921/**
20- * @var string Allow route pattern
22+ * Allow route pattern
23+ * in debug mode default value is "/^(gii|debug)/i".
24+ *
25+ * @var string
2126 */
22- public $ allowRegexp = '/(gii)/i ' ;
27+ public $ allowRegexp = '/^(gii)/i ' ;
28+
29+ /**
30+ * RouteAccessControl constructor.
31+ *
32+ * @param array $config
33+ */
34+ public function __construct (array $ config = [])
35+ {
36+ if (defined ('YII_DEBUG ' ) && YII_DEBUG ) {
37+ $ this ->allowRegexp = '/^(gii|debug)/i ' ;
38+ }
39+ parent ::__construct ($ config );
40+ }
2341
2442/**
2543 * This method is invoked right before an action is to be executed (after all possible filters.)
@@ -45,7 +63,7 @@ public function beforeAction($action)
4563}
4664
4765if (in_array ($ action_rule , $ this ->allowActions )
48- || in_array ($ controller_rule , $ this ->allowActions )
66+ || in_array ($ controller_rule , $ this ->allowActions )
4967) {
5068$ allow = true ;
5169} else {
@@ -63,7 +81,7 @@ public function beforeAction($action)
6381/**
6482 * Deny access method
6583 *
66- * @throws ForbiddenHttpException
84+ * @throws ForbiddenHttpException Deny exception.
6785 */
6886public function denyAccess ()
6987{
You can’t perform that action at this time.
0 commit comments