Beispiel #1
0
 /**
  * Processing nodes of the document before merging
  *
  * @param string $content
  * @return string
  */
 protected function processingDocument($content)
 {
     $object = new DataObject();
     $document = new \DOMDocument();
     $document->loadXML($content);
     $this->compiler->compile($document->documentElement, $object, $object);
     return $document->saveXML();
 }
Beispiel #2
0
 /**
  * Returns the string representation
  *
  * @return string
  */
 public function __toString()
 {
     try {
         $templateRootElement = $this->getDocumentElement();
         foreach ($templateRootElement->attributes as $name => $attribute) {
             if ('noNamespaceSchemaLocation' === $name) {
                 $this->getDocumentElement()->removeAttributeNode($attribute);
                 break;
             }
         }
         $templateRootElement->removeAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi');
         $this->compiler->compile($templateRootElement, $this->component, $this->component);
         $this->appendLayoutConfiguration();
         $result = $this->compiler->postprocessing($this->template->__toString());
     } catch (\Exception $e) {
         $result = '';
     }
     return $result;
 }
 /**
  * Compiles the Element node
  *
  * @param CompilerInterface $compiler
  * @param \DOMElement $node
  * @param DataObject $processedObject
  * @param DataObject $context
  * @return void
  */
 public function compile(CompilerInterface $compiler, \DOMElement $node, DataObject $processedObject, DataObject $context)
 {
     $ownerDocument = $node->ownerDocument;
     $parentNode = $node->parentNode;
     $document = new \DOMDocument();
     $document->loadXML($this->getContent($node->getAttribute(static::INCLUDE_PATH)));
     foreach ($this->getChildNodes($document->documentElement) as $child) {
         $compiler->compile($child, $processedObject, $context);
     }
     $newFragment = $ownerDocument->createDocumentFragment();
     foreach ($document->documentElement->childNodes as $child) {
         $newFragment->appendXML($document->saveXML($child));
     }
     $parentNode->replaceChild($newFragment, $node);
 }
Beispiel #4
0
 /**
  * Compiles the Element node
  *
  * @param CompilerInterface $compiler
  * @param \DOMElement $node
  * @param DataObject $processedObject
  * @param DataObject $context
  * @return void
  */
 public function compile(CompilerInterface $compiler, \DOMElement $node, DataObject $processedObject, DataObject $context)
 {
     foreach ($this->getChildNodes($node) as $child) {
         $compiler->compile($child, $processedObject, $context);
     }
 }