yii\filters\AccessRule::allows PHP Метод

allows() публичный Метод

Checks whether the Web user is allowed to perform the specified action.
public allows ( Action $action, User $user, Request $request ) : boolean | null
$action yii\base\Action the action to be performed
$user yii\web\User the user object
$request yii\web\Request
Результат boolean | null true if the user is allowed, false if the user is denied, null if the rule does not apply to the user
    public function allows($action, $user, $request)
    {
        if ($this->matchAction($action) && $this->matchRole($user) && $this->matchIP($request->getUserIP()) && $this->matchVerb($request->getMethod()) && $this->matchController($action->controller) && $this->matchCustom($action)) {
            return $this->allow ? true : false;
        } else {
            return null;
        }
    }

Usage Example

Пример #1
0
 /**
  * @see http://www.yiiframework.com/doc-2.0/yii-filters-accessrule.html#allows()-detail
  * 
  * Extends allows method with user role check
  */
 public function allows($action, $user, $request)
 {
     if (parent::allows($action, $user, $request) !== null && $this->matchUserRoles($user)) {
         return $this->allow ? true : false;
     }
     return null;
 }
All Usage Examples Of yii\filters\AccessRule::allows