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