Example #1
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;
 }
 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));
 }
Example #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'));
 }
Example #4
0
 protected function registerListeners(EventDispatcherInterface $dispatcher)
 {
     // $dispatcher->addListener takes two parameters: an event name, and a callable
     // Default events names can be found in Manialib\XML\Rendering\Events
     // There are some "global" events
     $dispatcher->addListener(Events::PRE_RENDER, array($this, 'preGlobalRender'));
     // But also some events related to the current instance.
     // Manialib\XML\Rendering\Events provides shortcuts to generate instance-related event names
     $dispatcher->addListener(Events::preRender($this), array($this, 'preThisRender'));
     // Full documetation of Event Dispatcher at
     // http://symfony.com/doc/current/components/event_dispatcher/index.html
 }
Example #5
0
 function registerListeners(EventDispatcherInterface $dispatcher)
 {
     parent::registerListeners($dispatcher);
     $dispatcher->addListener(Events::preRender($this), array($this, 'preFilterSize'));
 }