Skip to content
This repository was archived by the owner on Sep 19, 2023. It is now read-only.

Commit 970ca8a

Browse files
committed
Added debug panel to allow regexp by default
1 parent 59f7b84 commit 970ca8a

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/filters/RouteAccessControl.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,32 @@
1212
class 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
*/
1719
public $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

4765
if (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
*/
6886
public function denyAccess()
6987
{

0 commit comments

Comments
 (0)