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

Commit

Permalink
Added debug panel to allow regexp by default
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokopenko committed Apr 13, 2018
1 parent 59f7b84 commit 970ca8a
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/filters/RouteAccessControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,32 @@
class RouteAccessControl extends ActionFilter
{
/**
* @var array List of action that not need to check access.
* List of action that not need to check access.
*
* @var array
*/
public $allowActions = [];

/**
* @var string Allow route pattern
* Allow route pattern
* in debug mode default value is "/^(gii|debug)/i".
*
* @var string
*/
public $allowRegexp = '/(gii)/i';
public $allowRegexp = '/^(gii)/i';

/**
* RouteAccessControl constructor.
*
* @param array $config
*/
public function __construct(array $config = [])
{
if (defined('YII_DEBUG') && YII_DEBUG) {
$this->allowRegexp = '/^(gii|debug)/i';
}
parent::__construct($config);
}

/**
* This method is invoked right before an action is to be executed (after all possible filters.)
Expand All @@ -45,7 +63,7 @@ public function beforeAction($action)
}

if (in_array($action_rule, $this->allowActions)
|| in_array($controller_rule, $this->allowActions)
|| in_array($controller_rule, $this->allowActions)
) {
$allow = true;
} else {
Expand All @@ -63,7 +81,7 @@ public function beforeAction($action)
/**
* Deny access method
*
* @throws ForbiddenHttpException
* @throws ForbiddenHttpException Deny exception.
*/
public function denyAccess()
{
Expand Down

0 comments on commit 970ca8a

Please sign in to comment.