/** * Processes the opt:root node. * @internal * @param Opt_Xml_Node $node The recognized node. */ public function processNode(Opt_Xml_Node $node) { if ($node->getParent()->getType() != 'Opt_Xml_Root') { throw new Opt_InstructionInvalidParent_Exception($node->getXmlName(), 'ROOT'); } $params = array('escaping' => array(0 => self::OPTIONAL, self::BOOL, NULL), 'include' => array(0 => self::OPTIONAL, self::STRING, NULL), 'dynamic' => array(0 => self::OPTIONAL, self::BOOL, false)); $this->_extractAttributes($node, $params); // Compile-time inclusion support if (!is_null($params['include'])) { $file = $params['include']; if ($params['dynamic']) { if (is_null($file = $this->_compiler->inherits($this->_compiler->get('currentTemplate')))) { $file = $params['include']; } } $this->_compiler->addDependantTemplate($file); $compiler = new Opt_Compiler_Class($this->_compiler); $compiler->compile($this->_tpl->_getSource($file), $file, NULL, $this->_compiler->get('mode')); $this->_compiler->importDependencies($compiler); } // Escaping control support if (!is_null($params['escaping'])) { $this->_compiler->set('escaping', $params['escaping']); } $this->_process($node); }
/** * Finishes the processing of the opt:extend node. In this particular * case it handles the support of snippet extending, where the snippets * need to be scanned AFTER they are actually loaded. * * @internal * @param Opt_Xml_Node $node The recognized node. */ public function postprocessNode(Opt_Xml_Node $node) { if ($this->_compiler->processor('snippet')->isSnippet($node->get('branch'))) { $node->getParent()->set('snippet', $node->get('branch')); } else { $node->getParent()->set('extend', $node->get('branch')); } }
/** * A helper method for building the XML tree. It jumps out of the * current node to the parent and switches to it. * * @internal * @param Opt_Xml_Node $current The current node. * @return Opt_Xml_Node */ protected function _treeJumpOut($current) { $parent = $current->getParent(); if (!is_null($parent)) { return $parent; } return $current; }