public addRule ( boolean $allow, array | string $actions, mixed $resource, Closure | null $condition = null ) : array | |
||
$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 | |
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;
}