A valid template is a {DOMDocument} with some additional metadata.
Author: Asmir Mustafic (goetas@gmail.com)
Example #1
0
 /**
  * {@inheritdoc}
  */
 public function dump(Template $template)
 {
     $metadata = $template->getMetadata();
     $dom = $template->getDocument();
     $html5 = $this->getHtml5();
     return $html5->saveHTML($metadata['fragment'] ? $dom->childNodes : $dom);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function dump(Template $template)
 {
     $metadata = $template->getMetadata();
     $dom = $template->getDocument();
     $dom->preserveWhiteSpace = true;
     $dom->formatOutput = false;
     if ($metadata['xmldeclaration']) {
         return $dom->saveXML();
     } else {
         $xml = '';
         foreach ($dom->childNodes as $node) {
             $xml .= $dom->saveXML($node);
             if ($node instanceof \DOMDocumentType) {
                 $xml .= PHP_EOL;
             }
         }
         return $xml;
     }
 }