private function handleChildren(\blaze\web\component\UIComponent $parent, $children, $compositionChildren) { $prefixComponents = array('b' => 'blaze\\web\\component\\html\\', 'e' => 'blaze\\web\\component\\event\\'); foreach ($children as $node) { if ($node->nodeType == XML_ELEMENT_NODE) { if ($node->prefix == 'b' || $node->prefix == 'e') { $class = ClassWrapper::forName($prefixComponents[$node->prefix] . ucfirst($node->localName)); $component = $class->newInstance(); if ($node->hasAttributes()) { foreach ($node->attributes as $attribute) { if ($attribute->nodeType == XML_ATTRIBUTE_NODE) { $class->getMethod('set' . ucfirst($attribute->nodeName))->invoke($component, $attribute->nodeValue); } } } $parent->addChild($component); if ($node->hasChildNodes()) { $this->handleChildren($component, $node->childNodes, $compositionChildren); } } else { if ($node->prefix == 'ui') { if ($node->localName == 'insert') { if ($compositionChildren != null) { $foundElem = $this->findCompositionDefinition($compositionChildren, $node->getAttribute('name')); if ($foundElem == null) { $this->handleChildren($parent, $node->childNodes, $compositionChildren); } else { $this->handleChildren($parent, $foundElem->childNodes, $compositionChildren); } } else { $this->handleChildren($parent, $node->childNodes, $compositionChildren); } } else { if ($node->localName == 'composite') { $template = $node->getAttribute('template'); if ($template == '') { throw new Exception('No template view given'); } $f = new \blaze\io\File($this->viewDir, $template); if (!$f->exists()) { throw new \blaze\io\IOException('Template was not found'); } $root = $this->getRoot($parent); $newRoot = $this->parseAndCreateView($f, $node->childNodes); $newRoot->setViewId($root->getViewId()); $this->views->put($newRoot->getViewId(), $newRoot); } } } else { $tag = '<' . $node->nodeName; if ($node->hasAttributes()) { foreach ($node->attributes as $attribute) { if ($attribute->nodeType == XML_ATTRIBUTE_NODE) { $tag .= ' ' . $attribute->nodeName . '="' . $attribute->nodeValue . '"'; } } } $parent->addChild(\blaze\web\component\html\PlainText::create()->setValue($tag . '>')); if ($node->hasChildNodes()) { $this->handleChildren($parent, $node->childNodes, $compositionChildren); } $parent->addChild(\blaze\web\component\html\PlainText::create()->setValue('</' . $node->nodeName . '>')); } } } else { if ($node->nodeType == XML_TEXT_NODE) { $content = trim($node->textContent); if (strlen($content) != 0) { $parent->addChild(\blaze\web\component\html\PlainText::create()->setValue($content)); } } } } }
/** * {@inheritDoc} */ public function remove(\blaze\lang\String $key) { $f = new \blaze\io\File($this->cacheDir, $key); if ($f->exists()) { $f->delete(); } }