SimpleSAML_Metadata_SAMLParser::parseDescriptorsElement PHP Method

parseDescriptorsElement() public static method

This function parses a DOMElement which represents either an EntityDescriptor element or an EntitiesDescriptor element. It will return an associative array of SAMLParser instances in both cases.
public static parseDescriptorsElement ( DOMElement $element = null ) : SimpleSAML_Metadata_SAMLParser[]
$element DOMElement The DOMElement which contains the EntityDescriptor element or the EntitiesDescriptor element.
return SimpleSAML_Metadata_SAMLParser[] An associative array of SAMLParser instances. The key of the array will be the entity id.
    public static function parseDescriptorsElement(DOMElement $element = null)
    {
        if ($element === null) {
            throw new Exception('Document was empty.');
        }
        assert('$element instanceof DOMElement');
        if (SimpleSAML\Utils\XML::isDOMElementOfType($element, 'EntityDescriptor', '@md') === true) {
            return self::processDescriptorsElement(new \SAML2\XML\md\EntityDescriptor($element));
        } elseif (SimpleSAML\Utils\XML::isDOMElementOfType($element, 'EntitiesDescriptor', '@md') === true) {
            return self::processDescriptorsElement(new \SAML2\XML\md\EntitiesDescriptor($element));
        } else {
            throw new Exception('Unexpected root node: [' . $element->namespaceURI . ']:' . $element->localName);
        }
    }

Usage Example

示例#1
0
 /**
  * Parse XML metadata and return entities
  */
 private function loadXML($data, $source)
 {
     $entities = array();
     $doc = new DOMDocument();
     $res = $doc->loadXML($data);
     if ($res !== TRUE) {
         throw new Exception('Failed to read XML from ' . $source['src']);
     }
     if ($doc->documentElement === NULL) {
         throw new Exception('Opened file is not an XML document: ' . $source['src']);
     }
     $entities = SimpleSAML_Metadata_SAMLParser::parseDescriptorsElement($doc->documentElement);
     return $entities;
 }
All Usage Examples Of SimpleSAML_Metadata_SAMLParser::parseDescriptorsElement