eZ\Publish\Core\FieldType\RichText\Converter\Render\Template::convert PHP Method

convert() public method

Injects rendered payloads into template tag elements.
public convert ( DOMDocument $document ) : DOMDocument
$document DOMDocument
return DOMDocument
    public function convert(DOMDocument $document)
    {
        $xpath = new DOMXPath($document);
        $xpath->registerNamespace('docbook', 'http://docbook.org/ns/docbook');
        $xpathExpression = '//docbook:eztemplate | //docbook:eztemplateinline';
        $tags = $xpath->query($xpathExpression);
        /** @var \DOMElement[] $tagsSorted */
        $tagsSorted = array();
        $maxDepth = 0;
        foreach ($tags as $tag) {
            $depth = $this->getNodeDepth($tag);
            if ($depth > $maxDepth) {
                $maxDepth = $depth;
            }
            $tagsSorted[$depth][] = $tag;
        }
        krsort($tagsSorted, SORT_NUMERIC);
        foreach ($tagsSorted as $tags) {
            foreach ($tags as $tag) {
                $this->processTag($document, $tag);
            }
        }
        return $document;
    }