/** * Compiles the Element node * * @param Compiler $compiler * @param \DOMElement $node * @param UiComponentInterface $component * @param Object $context * @return void */ public function compile(Compiler $compiler, \DOMElement $node, UiComponentInterface $component, Object $context) { $name = $node->getAttribute('name'); $content = (string) $component->renderChildComponent($name); $name .= '_' . sprintf('%x', crc32(spl_object_hash($context))); if (!empty($content)) { $compiler->setPostprocessingData($name, $content); $newNode = $node->ownerDocument->createTextNode(Compiler::PATTERN_TAG . $name . Compiler::PATTERN_TAG); $node->parentNode->replaceChild($newNode, $node); } else { $node->parentNode->removeChild($node); } }
/** * 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 Compiler $compiler * @param \DOMElement $node * @param UiComponentInterface $component * @param Object $context * @return void */ public function compile(Compiler $compiler, \DOMElement $node, UiComponentInterface $component, Object $context) { foreach ($this->getChildNodes($node) as $child) { $compiler->compile($child, $component, $context); } }