adds a policy rule to the model.

@param $sec
@param $ptype
@param array $rule

@return bool
968278
public function addPolicy($sec, $ptype, array $rule)
    {
        if (!$this->hasPolicy($sec, $ptype, $rule)) {
            $this->model[$sec][$ptype]->policy[] = $rule;

            return true;
        }

        return false;
    }
398574
public function removeNamedGroupingPolicy($ptype, ...$params)
    {
        $ruleRemoved = false;
        if (1 == count($params) && is_array($params[0])) {
            $strSlice = $params[0];
            $ruleRemoved = $this->removePolicyInternal('g', $ptype, $strSlice);
        } else {
            $policy = [];
            foreach ($params as $param) {
                $policy[] = $param;
            }

            $ruleRemoved = $this->removePolicyInternal('g', $ptype, $policy);
        }

        if ($this->autoBuildRoleLinks) {
            $this->buildRoleLinks();
        }

        return $ruleRemoved;
    }
469182
public function isAllowed($role, $resource, $privilege): bool
    {
        // collect current acl
        $this->listCurrentAcl[$role . $resource . $privilege] = [
            'role'      => $role,
            'resource'  => $resource,
            'privilege' => $privilege,
        ];

        // for policy none
        if ($this->policy == self::POLICY_NONE) {
            return true;
        }

        // auto-fix missing resource in acl
        if ($resource && !isset($this->resource[$resource])) {
            $this->saveResource(['id' => null, 'resource' => $resource]);
        }
        return $this->permission->isAllowed($role, $resource, $privilege);
    }
70013
public function getFilteredPolicy($sec, $ptype, $fieldIndex, ...$fieldValues)
    {
        $res = [];

        foreach ($this->model[$sec][$ptype]->policy as $rule) {
            $matched = true;
            foreach ($fieldValues as $i => $fieldValue) {
                if ('' != $fieldValue && $rule[$fieldIndex + $i] != $fieldValue) {
                    $matched = false;

                    break;
                }
            }

            if ($matched) {
                $res[] = $rule;
            }
        }

        return $res;
    }
265109
public function createPolicy(Policy $policy, RoleAssignment $roleAssignment): UIValue\User\Policy
    {
        return new UIValue\User\Policy($policy, ['role_assignment' => $roleAssignment]);
    }
651127
protected function _addRules($type, array $rules, $resource, $resourceName) {
        if (!$type) {
            $type = Zend_Acl::TYPE_ALLOW;
        }
        foreach ($rules as $privilege => $ruleProperties) {
            // If the user sets the privilege value to a string, we will consider
            // this as the list of roles.
            if (!is_array($ruleProperties)) {
                $ruleProperties = array('roles' => $ruleProperties);
            }

            if ($privilege === 'all') {
                $privilege = null;
            }

            $roles = $ruleProperties['roles'];

            if (is_null($roles) || empty($roles)) {
                $section = 'rules';
                if ($type === Zend_Acl::TYPE_ALLOW) {
                    $section = 'allow ' . $section;
                } else {
                    $section = 'deny ' . $section;
                }

                throw new Zend_Application_Resource_Exception(
                    sprintf(
                        $this->_missingPropertyMessage,
                        'roles',
                        $section,
                        'resource ' . $resourceName
                    )
                );
            }

            $roles = explode(',', $roles);

            if ($roles[0] === 'all') {
                $roles = null;
            }

            $assert = null;

            if (isset($ruleProperties['assert']) && !empty($ruleProperties['assert'])) {
                $assert = $ruleProperties['assert'];
                $assert = new $assert();
            }

            $this->_acl->setRule(
                Zend_Acl::OP_ADD,
                $type,
                $roles,
                $resource,
                $privilege,
                $assert
            );
        }
    }
15909
def _add_rule(self, group, role, value):
        """"""
        if role not in group:
            group[role] = list()

        group[role].append(value)

        self.invalidate()
984147
public function setRule($rule)
	{
		if(null === $rule)
		{
			$rule = Dispatch::module() . '/' . Dispatch::control() . '/' . Dispatch::action();
		}
		$this->rule = $rule;
	}
755224
public function addRule(RuleAbstract $rule)
    {
        // TODO Keyframes with duplicate identifiers do NOT cascade!
        // Last one overwrites previous ones.
        // @see https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes#Duplicate_resolution

        if ($rule instanceof KeyframesRuleSet) {
            $this->rules[] = $rule;
        } else {
            throw new \InvalidArgumentException(
                "Invalid rule instance. Instance of 'KeyframesRuleSet' expected."
            );
        }

        return $this;
    }
895570
public function in($rule) {
        $this->check_role = 'in';
        if (!is_array($rule)) {
            $rule = explode(',', $rule);
        }
        $this->rule = '[' . explode(',', $rule) . ']';
        $result = in_array($this->value, $rule);
        $this->checkResult($result);
        return $this;
    }
444528
public static function add_filter($rule, $callback)
    {
        $method = 'filter_'.$rule;

        if (method_exists(__CLASS__, $method) || isset(self::$filter_methods[$rule])) {
            throw new Exception("Filter rule '$rule' already exists.");
        }

        self::$filter_methods[$rule] = $callback;

        return true;
    }
171580
@Override
    public void removePolicy(String sec, String ptype, List<String> rule) {
        throw new Error("not implemented");
    }
893331
public boolean addPolicy(String sec, String ptype, List<String> rule) {
        if (!hasPolicy(sec, ptype, rule)) {
            model.get(sec).get(ptype).policy.add(rule);
            return true;
        }
        return false;
    }
1125246
public function add($type, Rule $rule)
    {
        if (!isset($this[$type])) {
            $this[$type] = [];
        }

        if ($rule->language === false) {
            $rule->language = $this->_language;
        }

        if ($rule->validator === false) {
            $rule->validator = $this->validator;
        }

        $rule->factory->setBase($type);

        if ($rule->name !== null) {
            if (isset($this[$type][$rule->name])) {
                throw new NameConflictException("Rule with '{$rule->name}' is already defined, name has to be unique!");
            }

            $this[$type][$rule->name] = $rule;
            return;
        }

        $this[$type][] = $rule;
    }
1297922
private function queryAddSimpleAccessPolicyCondition($policy_name, $policy, $query, $clause)
	{
		$policy_alias = $clause == 'select' ? ' AS '.$query->quoteIdent('_access_policy_'.$policy_name) : '';
		if ($this->auth->isAllMighty()) {
			$query->$clause('TRUE'.$policy_alias);
		} else {
			$query->$clause('('.$policy['sql_select'].')'.$policy_alias);
		}
	}
598547
public function addRule(Rule $rule)
    {
        $classname = $rule->getClass();
        if ($this->hasRule($classname) === true) {
            throw new Exception(
                "failed to add rule; the field {$this->name} already has an ".
                "instance of '$classname'"
            );
        }
        else if ($classname === Rule::REQUIRED) {
            $this->rules = [$classname => $rule] + $this->rules;
        }
        else {
            $this->rules[$classname] = $rule;
        }
        return $this;
    }
1319556
public boolean removePolicy(String sec, String ptype, List<String> rule) {
        for (int i = 0; i < model.get(sec).get(ptype).policy.size(); i ++) {
            List<String> r = model.get(sec).get(ptype).policy.get(i);
            if (Util.arrayEquals(rule, r)) {
                model.get(sec).get(ptype).policy.remove(i);
                return true;
            }
        }

        return false;
    }