Adds limitations to an existing policy.

@param int $policyId
@param array $limitations
421285
public function addPolicyLimitations($policyId, array $limitations)
    {
        try {
            return $this->innerGateway->addPolicyLimitations($policyId, $limitations);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
1083558
public void setPolicyList(java.util.Collection<PolicySummary> policyList) {
        if (policyList == null) {
            this.policyList = null;
            return;
        }

        this.policyList = new java.util.ArrayList<PolicySummary>(policyList);
    }
1183694
private function areObjectStatesMatchingTheLimitation(array $objectStateIds, array $limitationValues)
    {
        foreach ($objectStateIds as $objectStateId) {
            // check using loose types as limitation values are strings and id's can be int
            if (!in_array($objectStateId, $limitationValues)) {
                return false;
            }
        }

        return true;
    }
1152945
public function addPermission($roleId, $resourceId)
    {
        $this->aclDataService->createRule(
            $this->getAclRule($roleId, $resourceId)
        );
    }
886250
private function initializeObjectDataPolicies(PolicyIdListInterface $policies)
    {
        foreach ($policies->getPolicyIds() as $policyId) {
            $policy = $this->getSession()->getObject($this->getSession()->createObjectId($policyId));
            if ($policy instanceof PolicyInterface) {
                $this->policies[] = $policy;
            }
        }

        $this->extensions[(string) ExtensionLevel::POLICIES] = $policies->getExtensions();
    }
47313
protected function prepare_policy($policyid, $versionid) {

        if ($versionid) {
            $this->policy = api::get_policy_version($versionid);

        } else {
            $this->policy = array_reduce(api::list_current_versions(), function ($carry, $current) use ($policyid) {
                if ($current->policyid == $policyid) {
                    return $current;
                }
                return $carry;
            });
        }

        if (empty($this->policy)) {
            throw new \moodle_exception('errorpolicyversionnotfound', 'tool_policy');
        }
    }
1166842
public void addPolicy(Policy policy) throws PolicyException {

        // Add BlueprintPolicy
        if (policy instanceof BlueprintPolicy) {
            if (erectors.get(policy.getTarget()) == null) {
                throw new PolicyException("Blueprint does not exist for BlueprintPolicy target: " + policy.getTarget());
            }

            List<BlueprintPolicy> policies = blueprintPolicies.get(policy.getTarget());
            if (policies == null) {
                policies = new ArrayList<BlueprintPolicy>();
            }

            policies.add((BlueprintPolicy) policy);

            logger.info("Setting BlueprintPolicy {} for {}", policy, policy.getTarget());

            blueprintPolicies.put(policy.getTarget(), policies);

            // Add FieldPolicy
        } else if (policy instanceof FieldPolicy) {

            // XXX: force FieldPolicy's to be mapped to a blueprint? Limits their scope, but enables validation
            if (erectors.get(policy.getTarget()) == null) {
                throw new PolicyException("Blueprint does not exist for FieldPolicy target: " + policy.getTarget());
            }

            List<FieldPolicy> policies = fieldPolicies.get(policy.getTarget());
            if (policies == null) {
                policies = new ArrayList<FieldPolicy>();
            }

            policies.add((FieldPolicy) policy);

            logger.info("Setting FieldPolicy {} for {}", policy, policy.getTarget());

            fieldPolicies.put(policy.getTarget(), policies);
        }
    }
739559
public function setLimit($limit)
    {
        if (!isset($this->_persistence) || !($this->_persistence instanceof IPersistance)) {
            throw new Exception("Repository Exception : No existe la interfaz de la persistencia o no implementa la interfaz IPersistance.");
        }

        $this->_persistence->setLimit($limit);

        return $this;
    }
545994
static function createNew( $policyID, $identifier )
    {
        $policyParameter = new eZPolicyLimitation( array() );
        $policyParameter->setAttribute( 'policy_id', $policyID );
        $policyParameter->setAttribute( 'identifier', $identifier );
        $policyParameter->store();

        return $policyParameter;
    }
391882
private function isStateGroupUsedForLimitation($stateGroupId, array $limitationValues)
    {
        $objectStateHandler = $this->persistence->objectStateHandler();
        $states = $objectStateHandler->loadObjectStates($stateGroupId);

        foreach ($states as $state) {
            // check using loose types as limitation values are strings and id's can be int
            if (in_array($state->id, $limitationValues)) {
                return true;
            }
        }

        return false;
    }
687427
public function loadPolicies($roleId, Request $request)
    {
        $loadedRole = $this->roleService->loadRole($roleId);

        return new Values\PolicyList($loadedRole->getPolicies(), $request->getPathInfo());
    }
462710
public function policyConstraints(): Ext\PolicyConstraintsExtension
    {
        /** @var Extension\PolicyConstraintsExtension $policyConstraints */
        $policyConstraints = $this->get(Ext\Extension::OID_POLICY_CONSTRAINTS);
        return $policyConstraints;
    }
648946
public function buildPersistencePolicyObject($module, $function, array $limitations)
    {
        $limitationsToCreate = '*';
        if ($module !== '*' && $function !== '*' && !empty($limitations)) {
            $limitationsToCreate = array();
            foreach ($limitations as $limitation) {
                $limitationsToCreate[$limitation->getIdentifier()] = $limitation->limitationValues;
            }
        }

        return new SPIPolicy(
            array(
                'module' => $module,
                'function' => $function,
                'limitations' => $limitationsToCreate,
            )
        );
    }
991074
public function updatePolicy(Policy $policy)
    {
        $policy = clone $policy;
        $this->limitationConverter->toLegacy($policy);

        $this->roleGateway->removePolicyLimitations($policy->id);
        $this->roleGateway->addPolicyLimitations($policy->id, $policy->limitations === '*' ? array() : $policy->limitations);
    }
875543
public function limits($limits = NULL) {
        if (isset($limits)) {
            if (is_int($limits)) {
                $this->setLimits($limits);
                return $this;
            }
        }
        return $this->getLimits();
    }
1270110
static function removeByValue( $value, $policyID = false )
    {
        if ( $policyID )
        {
            $limitationIDList = array();
            $limitations = eZPolicyLimitation::fetchByPolicyID( $policyID, false );
            foreach ( $limitations as $limitationArray )
            {
                $limitationIDList[] = $limitationArray['id'];
            }
            if  ( count( $limitationIDList ) > 0 )
            {
                eZPersistentObject::removeObject( eZPolicyLimitationValue::definition(),
                                                  array( 'limitation_id' => array( $limitationIDList  ),
                                                         "value" => $value ) );
                return;
            }
        }
        eZPersistentObject::removeObject( eZPolicyLimitationValue::definition(),
                                          array( "value" => $value ) );
    }
162549
public void addPolicy(final Enum name, final ExpirationPolicy policy) {
        LOGGER.trace("Adding expiration policy [{}] with name [{}]", policy, name);
        addPolicy(name.name(), policy);
    }