protected function flattenLinksInLinks(DOMDocument $document, $contentFieldId)
    {
        $xpath = new DOMXPath($document);

        // Get all link elements which are child of a link
        $xpathExpression = '//link[parent::link]';

        $links = $xpath->query($xpathExpression);

        foreach ($links as $link) {
            // Move link to parent
            $targetElement = $link->parentNode->parentNode;
            $parentLink = $link->parentNode;
            $targetElement->insertBefore($link, $parentLink);

            // We want parent link to be listed first.
            $targetElement->insertBefore($parentLink, $link);

            $this->log(LogLevel::NOTICE, "Found nested links. Flatten links where contentobject_attribute.id=$contentFieldId");
        }
    }
protected function flattenLinksInLinks(DOMDocument $document, $contentFieldId)
    {
        $xpath = new DOMXPath($document);

        // Get all link elements which are child of a link
        $xpathExpression = '//link[parent::link]';

        $links = $xpath->query($xpathExpression);

        foreach ($links as $link) {
            // Move link to parent
            $targetElement = $link->parentNode->parentNode;
            $parentLink = $link->parentNode;
            $targetElement->insertBefore($link, $parentLink);

            // We want parent link to be listed first.
            $targetElement->insertBefore($parentLink, $link);

            $this->log(LogLevel::NOTICE, "Found nested links. Flatten links where contentobject_attribute.id=$contentFieldId");
        }
    }
protected function flattenLinksInLinks ( DOMDocument $ document , $ contentFieldId ) { $ xpath = new DOMXPath ( $ document ) ; // Get all link elements which are child of a link $ xpathExpression = '//link[parent::link]' ; $ links = $ xpath -> query ( $ xpathExpression ) ; foreach ( $ links as $ link ) { // Move link to parent $ targetElement = $ link -> parentNode -> parentNode ; $ parentLink = $ link -> parentNode ; $ targetElement -> insertBefore ( $ link , $ parentLink ) ; // We want parent link to be listed first. $ targetElement -> insertBefore ( $ parentLink , $ link ) ; $ this -> log ( LogLevel :: NOTICE , "Found nested links. Flatten links where contentobject_attribute.id=$contentFieldId" ) ; } }
ezxmltext may contain link elements below another link element. This method flattens such structure.

@param DOMDocument $document
@param int|null $contentFieldId
ezxmltext may contain link elements below another link element . This method flattens such structure .