protected function getElement(NodeInterface $node)
 {
     $this->eventDispatcher->dispatch(Events::preRender($node));
     // XML fragment?
     if ($node instanceof FragmentInterface) {
         return $this->appendXML($node->getNodeValue());
     }
     // Create
     $this->writer->startElement($node->getNodeName());
     // Attributes
     // With XMLWriter, attributes must be written prior to content and children
     // See http://www.php.net/manual/en/function.xmlwriter-write-attribute.php#103498
     foreach ($node->getAttributes() as $name => $value) {
         $this->writer->writeAttribute($name, $value);
     }
     // Value
     if ($node->getNodeValue() !== null) {
         $this->writer->text($node->getNodeValue());
     }
     // Children
     foreach ($node->getChildren() as $child) {
         $this->getElement($child);
     }
     // End create
     $this->writer->endElement();
     $this->eventDispatcher->dispatch(Events::postRender($node));
 }
Exemple #2
0
 protected function getElement(NodeInterface $node)
 {
     $this->eventDispatcher->dispatch(Events::preRender($node));
     // XML fragment?
     if ($node instanceof FragmentInterface) {
         return $this->appendXML($node->getNodeValue());
     }
     // Create
     $element = $this->document->createElement($node->getNodeName());
     // Value
     if ($node->getNodeValue() !== null) {
         $element->appendChild($this->document->createTextNode($node->getNodeValue()));
     }
     // Attributes
     foreach ($node->getAttributes() as $name => $value) {
         $element->setAttribute($name, $value);
     }
     // Children
     foreach ($node->getChildren() as $child) {
         $subelement = $this->getElement($child);
         $element->appendChild($subelement);
     }
     $this->eventDispatcher->dispatch(Events::postRender($node));
     return $element;
 }
Exemple #3
0
 public function registerListeners(EventDispatcherInterface $dispatcher)
 {
     // Pre-render filters
     $dispatcher->addListener(Events::preRender($this), array($this, 'preFilterLayout'));
     $dispatcher->addListener(Events::preRender($this), array($this, 'preFilterRelativePosition'));
     // Post-render filters
     $dispatcher->addListener(Events::postRender($this), array($this, 'postFilterLayout'));
 }