@param DOMElement $restriction

@return void
500310
protected function init(DOMElement $restriction)
    {
        $conditionNodes = XmlUtil::getChildElements($restriction, 'conditions');

        foreach ($conditionNodes as $condition) {
            $conditionDescriptor = DescriptorFactory::getFactory()->createConditionsDescriptor($condition);
            $conditionDescriptor->setParent($this);
            $this->conditions->attach($conditionDescriptor);
        }
    }
1270715
protected function validateRules($rules, User $user, array $restriction)
    {
        $return = array('validRules' => 0, 'rules' => array());

        if (0 < count($rules)) {
            foreach ($rules as $rule) {
                $rule->setUser($user);
                $checkedLogs = $this->validateRule($rule, $restriction);

                if (false !== $checkedLogs) {
                    $return['validRules']++;
                    $return['rules'][] = array(
                        'rule' => $rule, 'logs' => $checkedLogs
                    );
                }
            }
        }

        return $return;
    }
225277
public function killBreaks(\DOMElement $node)
    {
        $html = $node->getInnerHTML();
        $html = preg_replace($this->regexps['killBreaks'], '<br />', $html);
        $node->setInnerHtml($html);
    }
6833
public function setTemplateExtension($extension)
    {
        $extension = (string) $extension;
        $extension = trim($extension);
        if ('.' == $extension[0]) {
            $extension = substr($extension, 1);
        }

        $this->extension = $extension;
    }
552616
protected function init(DOMElement $element)
    {
        $this->parseType($element);
        $this->parseId($element, false);
        $this->parseName($element, false);

        $this->parseArgs($element);
    }
683364
public function setMaxLength($limit) {
        if(!empty($limit))
            $this->validation[] = new Validation\MaxLength($limit);
        $this->_attributes["maxlength"] = $limit;
    }
1329659
protected function visitLimitation(Generator $generator, Limitation $limitation)
    {
        $generator->startHashElement('limitation');

        $generator->startAttribute('identifier', $limitation->getIdentifier());
        $generator->endAttribute('identifier');

        $generator->startHashElement('values');
        $generator->startList('ref');

        foreach ($limitation->limitationValues as $limitationValue) {
            $generator->startObjectElement('ref');
            $generator->startAttribute('href', $limitationValue);
            $generator->endAttribute('href');
            $generator->endObjectElement('ref');
        }

        $generator->endList('ref');
        $generator->endHashElement('values');

        $generator->endHashElement('limitation');
    }
862980
public function register(Extension $extension)
    {
        if ($extension instanceof DocumentExtension) {
            array_unshift($this->registry[DocumentExtension::class], $extension);
        }
        if ($extension instanceof ElementExtension) {
            array_unshift($this->registry[ElementExtension::class], $extension);
        }
        if ($extension instanceof NamespaceExtension) {
            $this->registry[NamespaceExtension::class][] = $extension;
        }
    }
889951
protected function addClass(\DOMElement $element, $class)
    {
        if ($element->hasAttribute('class')) {
            $element->setAttribute('class', $element->getAttribute('class') . ' ' . $class);
        } else {
            $element->setAttribute('class', $class);
        }
    }
814956
protected function _setBlock($block)
    {
        if ($block !== null && !($block instanceof BlockInterface)) {
            throw $this->_createInvalidArgumentException(
                $this->__('Invalid block'),
                null,
                null,
                $block
            );
        }

        $this->block = $block;
    }
768006
protected function checkElementNode(DOMElement $element, Tag $tag)
	{
		$xpath = new DOMXPath($element->ownerDocument);

		// If current node is not an <xsl:attribute/> element, we exclude descendants
		// with an <xsl:attribute/> ancestor so that content such as:
		//   <script><xsl:attribute name="id"><xsl:value-of/></xsl:attribute></script>
		// would not trigger a false-positive due to the presence of an <xsl:value-of/>
		// element in a <script>
		$predicate = ($element->localName === 'attribute') ? '' : '[not(ancestor::xsl:attribute)]';

		// Test the select expression of <xsl:value-of/> nodes
		$query = './/xsl:value-of' . $predicate;
		foreach ($xpath->query($query, $element) as $valueOf)
		{
			$this->checkSelectNode($valueOf->getAttributeNode('select'), $tag);
		}

		// Reject all <xsl:apply-templates/> nodes
		$query = './/xsl:apply-templates' . $predicate;
		foreach ($xpath->query($query, $element) as $applyTemplates)
		{
			throw new UnsafeTemplateException('Cannot allow unfiltered data in this context', $applyTemplates);
		}
	}
124590
public function setTagLimit($limit)
	{
		$limit = (int) $limit;

		if ($limit < 1)
		{
			throw new InvalidArgumentException('tagLimit must be a number greater than 0');
		}

		$this->tagLimit = $limit;
	}
652032
protected function init(DOMElement $register)
    {
        $this->parseType($register);
        $this->variableName = XmlUtil::getRequiredAttributeValue($register, 'variable-name');

        $this->parseId($register, false);


        $this->parseArgs($register);
    }
955387
private function parseSignature(DOMElement $xml) : void
    {
        /** @var \DOMAttr[] $signatureMethod */
        $signatureMethod = Utils::xpQuery($xml, './ds:Signature/ds:SignedInfo/ds:SignatureMethod/@Algorithm');

        /* Validate the signature element of the message. */
        $sig = Utils::validateElement($xml);
        if ($sig !== false) {
            $this->wasSignedAtConstruction = true;
            $this->setCertificates($sig['Certificates']);
            $this->setSignatureData($sig);
            $this->setSignatureMethod($signatureMethod[0]->value);
        }
    }
649414
public function getEvents($restriction = null)
    {
        $suffixLogPath      = '/Event/Log';
        $suffixLogNamespace = '\Event\Log';
        $bundles            = $this->kernel->getBundles();
        $events          = array();

        foreach ($bundles as $bundle) {
            $bundleEventLogDirectory = $bundle->getPath() . $suffixLogPath;
            if (file_exists($bundleEventLogDirectory)) {
                $finder = new Finder();
                $finder->files()->in($bundleEventLogDirectory)->sortByName();
                $events = array_merge(
                    $events,
                    $this->getEventsByBundle($finder, $bundle->getNamespace(), $suffixLogNamespace, $restriction)
                );
            }
        }

        return $events;
    }
253986
private function addEncryptedAttributeStatement(DOMElement $root) : void
    {
        if ($this->getRequiredEncAttributes() === false) {
            return;
        }
        Assert::notNull($this->encryptionKey);

        $document = $root->ownerDocument;

        $attributeStatement = $document->createElementNS(Constants::NS_SAML, 'saml:AttributeStatement');
        $root->appendChild($attributeStatement);

        foreach ($this->attributes as $name => $values) {
            $document2 = DOMDocumentFactory::create();
            $attribute = $document2->createElementNS(Constants::NS_SAML, 'saml:Attribute');
            $attribute->setAttribute('Name', $name);
            $document2->appendChild($attribute);

            if ($this->nameFormat !== Constants::NAMEFORMAT_UNSPECIFIED) {
                $attribute->setAttribute('NameFormat', $this->getAttributeNameFormat());
            }

            foreach ($values as $value) {
                if (is_string($value)) {
                    $type = 'xs:string';
                } elseif (is_int($value)) {
                    $type = 'xs:integer';
                } else {
                    $type = null;
                }

                $attributeValue = $document2->createElementNS(Constants::NS_SAML, 'saml:AttributeValue');
                $attribute->appendChild($attributeValue);
                if ($type !== null) {
                    $attributeValue->setAttributeNS(Constants::NS_XSI, 'xsi:type', $type);
                }

                if ($value instanceof DOMNodeList) {
                    foreach ($value as $v) {
                        $node = $document2->importNode($v, true);
                        $attributeValue->appendChild($node);
                    }
                } else {
                    $value = strval($value);
                    $attributeValue->appendChild($document2->createTextNode($value));
                }
            }
            /*Once the attribute nodes are built, the are encrypted*/
            $EncAssert = new XMLSecEnc();
            $EncAssert->setNode($document2->documentElement);
            $EncAssert->type = 'http://www.w3.org/2001/04/xmlenc#Element';
            /*
             * Attributes are encrypted with a session key and this one with
             * $EncryptionKey
             */
            $symmetricKey = new XMLSecurityKey(XMLSecurityKey::AES256_CBC);
            $symmetricKey->generateSessionKey();
            /** @psalm-suppress PossiblyNullArgument */
            $EncAssert->encryptKey($this->encryptionKey, $symmetricKey);
            /** @psalm-suppress UndefinedClass */
            $EncrNode = $EncAssert->encryptNode($symmetricKey);

            $EncAttribute = $document->createElementNS(Constants::NS_SAML, 'saml:EncryptedAttribute');
            $attributeStatement->appendChild($EncAttribute);
            /** @psalm-suppress InvalidArgument */
            $n = $document->importNode($EncrNode, true);
            $EncAttribute->appendChild($n);
        }
    }
714859
private function doesKeySatisfyRestrictions(array $restrictions, JWKInterface $key)
    {
        foreach ($restrictions as $k => $v) {
            if (!$key->has($k) || $v !== $key->get($k)) {
                return false;
            }
        }

        return true;
    }