yii\base\ActionFilter::isActive PHP Метод

isActive() защищенный Метод

Returns a value indicating whether the filter is active for the given action.
protected isActive ( Action $action ) : boolean
$action Action the action being filtered
Результат boolean whether the filter is active for the given action.
    protected function isActive($action)
    {
        $id = $this->getActionId($action);
        if (empty($this->only)) {
            $onlyMatch = true;
        } else {
            $onlyMatch = false;
            foreach ($this->only as $pattern) {
                if (fnmatch($pattern, $id)) {
                    $onlyMatch = true;
                    break;
                }
            }
        }
        $exceptMatch = false;
        foreach ($this->except as $pattern) {
            if (fnmatch($pattern, $id)) {
                $exceptMatch = true;
                break;
            }
        }
        return !$exceptMatch && $onlyMatch;
    }

Usage Example

Пример #1
0
 /**
  * {@inheritdoc}
  */
 protected function isActive($action)
 {
     return parent::isActive($action) || $this->isOptional($action);
 }