Authority\Authority::addRule PHP Method

addRule() public method

Define rule for a given action and resource
public addRule ( boolean $allow, array | string $actions, mixed $resource, Closure | null $condition = null ) : array | Rule
$allow boolean True if privilege, false if restriction
$actions array | string Action for the rule
$resource mixed Resource for the rule
$condition Closure | null Optional condition for the rule
return array | Rule
    public function addRule($allow, $actions, $resource, $condition = null)
    {
        $rules = array();
        $actions = (array) $actions;
        foreach ($actions as $action) {
            $rule = new Rule($allow, $action, $resource, $condition);
            $this->rules->add($rule);
            $rules[] = $rule;
        }
        return count($rules) === 1 ? $rules[0] : $rules;
    }