SAML2\XML\Chunk::toXML PHP Méthode

toXML() public méthode

Append this XML element to a different XML element.
public toXML ( DOMElement $parent ) : DOMElement
$parent DOMElement The element we should append this element to.
Résultat DOMElement The new element.
    public function toXML(\DOMElement $parent)
    {
        return Utils::copyElement($this->xml, $parent);
    }

Usage Example

Exemple #1
0
 /**
  * Add a AuthnStatement-node to the assertion.
  *
  * @param \DOMElement $root The assertion element we should add the authentication statement to.
  */
 private function addAuthnStatement(\DOMElement $root)
 {
     if ($this->authnInstant === null || $this->authnContextClassRef === null && $this->authnContextDecl === null && $this->authnContextDeclRef === null) {
         /* No authentication context or AuthnInstant => no authentication statement. */
         return;
     }
     $document = $root->ownerDocument;
     $authnStatementEl = $document->createElementNS(Constants::NS_SAML, 'saml:AuthnStatement');
     $root->appendChild($authnStatementEl);
     $authnStatementEl->setAttribute('AuthnInstant', gmdate('Y-m-d\\TH:i:s\\Z', $this->authnInstant));
     if ($this->sessionNotOnOrAfter !== null) {
         $authnStatementEl->setAttribute('SessionNotOnOrAfter', gmdate('Y-m-d\\TH:i:s\\Z', $this->sessionNotOnOrAfter));
     }
     if ($this->sessionIndex !== null) {
         $authnStatementEl->setAttribute('SessionIndex', $this->sessionIndex);
     }
     $authnContextEl = $document->createElementNS(Constants::NS_SAML, 'saml:AuthnContext');
     $authnStatementEl->appendChild($authnContextEl);
     if (!empty($this->authnContextClassRef)) {
         Utils::addString($authnContextEl, Constants::NS_SAML, 'saml:AuthnContextClassRef', $this->authnContextClassRef);
     }
     if (!empty($this->authnContextDecl)) {
         $this->authnContextDecl->toXML($authnContextEl);
     }
     if (!empty($this->authnContextDeclRef)) {
         Utils::addString($authnContextEl, Constants::NS_SAML, 'saml:AuthnContextDeclRef', $this->authnContextDeclRef);
     }
     Utils::addStrings($authnContextEl, Constants::NS_SAML, 'saml:AuthenticatingAuthority', false, $this->AuthenticatingAuthority);
 }
All Usage Examples Of SAML2\XML\Chunk::toXML