/** * visitReturnTstNode * * @param ezcTemplateReturnTstNode $type * @return ezcTemplateAstNode */ public function visitReturnTstNode(ezcTemplateReturnTstNode $type) { $astNodes = array(); foreach ($type->variables as $var => $expr) { $assign = new ezcTemplateAssignmentOperatorAstNode(); $assign->appendParameter($this->createVariableNode("this->receive->" . $var)); if ($expr === null) { $symType = $this->parser->symbolTable->retrieve($var); if ($symType == ezcTemplateSymbolTable::IMPORT) { $assign->appendParameter($this->createVariableNode("this->send->" . $var)); } else { $assign->appendParameter($this->createTemplateVariableNode($var)); } } else { $assign->appendParameter($expr->accept($this)); } $astNodes[] = new ezcTemplateGenericStatementAstNode($assign); } $astNodes[] = new ezcTemplateReturnAstNode($this->outputVariable->getAst()); return $astNodes; }
public function visitReturnTstNode(ezcTemplateReturnTstNode $node) { if ($this->isInDynamicBlock) { // Do not add additional cache stuff, because that is written by the dynamic block. return parent::visitReturnTstNode($node); } $astNodes = array(); foreach ($node->variables as $var => $expr) { $assign = new ezcTemplateAssignmentOperatorAstNode(); $assign->appendParameter($this->createVariableNode("this->receive->" . $var)); if ($expr === null) { if ($this->parser->symbolTable->retrieve($var) == ezcTemplateSymbolTable::IMPORT) { $assign->appendParameter($this->createVariableNode("this->send->" . $var)); } else { $assign->appendParameter($this->createVariableNode($var)); } } else { $assign->appendParameter($expr->accept($this)); } $astNodes[] = new ezcTemplateGenericStatementAstNode($assign); // Add the cache . $astNodes[] = $this->_fwriteVarExportVariable("this->receive->" . $var, false, false); } // Some extra stuff. $astNodes[] = $this->_fwriteVarExportVariable(self::INTERNAL_PREFIX . "output", true, true); // $total .= $_ezcTemplate_output; $astNodes[] = $this->_concatAssignVariable(self::INTERNAL_PREFIX . "output", "total" . $this->cacheLevel); // fclose($fp); $astNodes[] = $this->_fclose(); // $_ezcTemplate_output = $total; $astNodes[] = $this->_assignVariable("total" . $this->cacheLevel, self::INTERNAL_PREFIX . "output"); $astNodes[] = new ezcTemplateReturnAstNode($this->outputVariable->getAst()); return $astNodes; }
/** * Appends an assignment operator to the current body and returns $this. * The left hand side can either be a code element or a string which * is turned into an ezcTemplateVariableAstNode object. * The right hand side can either be a code element or a PHP type which * is turned into an ezcTemplateLiteralAstNode object. * * @param mixed $lhs The left hand side of the expression. * @param mixed $rhs The right hand side of the expression. * @return ezcTemplateAstBuilder */ public function assign($lhs, $rhs) { if (!is_object($lhs) || !$lhs instanceof ezcTemplateAstNode) { $lhs = new ezcTemplateVariableAstNode($lhs); } if (!is_object($rhs) || !$rhs instanceof ezcTemplateAstNode) { $rhs = new ezcTemplateLiteralAstNode($rhs); } $assignment = new ezcTemplateAssignmentOperatorAstNode(); $assignment->appendParameter($lhs); $assignment->appendParameter($rhs); $this->currentBody->appendStatement(new ezcTemplateGenericStatementAstNode($assignment)); return $this; }