XMLSecurityDSig::auxKeyInfo PHP Method

auxKeyInfo() static public method

static public auxKeyInfo ( $parentRef, $xpath = null )
    static function auxKeyInfo($parentRef, $xpath = null)
    {
        $baseDoc = $parentRef->ownerDocument;
        if (empty($xpath)) {
            $xpath = new DOMXPath($parentRef->ownerDocument);
            $xpath->registerNamespace('secdsig', XMLSecurityDSig::XMLDSIGNS);
        }
        $query = "./secdsig:KeyInfo";
        $nodeset = $xpath->query($query, $parentRef);
        $keyInfo = $nodeset->item(0);
        if (!$keyInfo) {
            $inserted = false;
            $keyInfo = $baseDoc->createElementNS(XMLSecurityDSig::XMLDSIGNS, 'ds:KeyInfo');
            $query = "./secdsig:Object";
            $nodeset = $xpath->query($query, $parentRef);
            if ($sObject = $nodeset->item(0)) {
                $sObject->parentNode->insertBefore($keyInfo, $sObject);
                $inserted = true;
            }
            if (!$inserted) {
                $parentRef->appendChild($keyInfo);
            }
        }
        return array($parentRef, $keyInfo);
    }