本文整理汇总了PHP中PHPTAL_Php_CodeWriter::pushContext方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPTAL_Php_CodeWriter::pushContext方法的具体用法?PHP PHPTAL_Php_CodeWriter::pushContext怎么用?PHP PHPTAL_Php_CodeWriter::pushContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPTAL_Php_CodeWriter
的用法示例。
在下文中一共展示了PHPTAL_Php_CodeWriter::pushContext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
public function before(PHPTAL_Php_CodeWriter $codewriter)
{
$this->var = $codewriter->createTempVariable();
// alias to repeats handler to avoid calling extra getters on each variable access
$codewriter->doSetVar($this->var, '$ctx->repeat');
list($varName, $expression) = $this->parseSetExpression($this->expression);
$code = $codewriter->evaluateExpression($expression);
// instantiate controller using expression
$codewriter->doSetVar($this->var . '->' . $varName, 'new PHPTAL_RepeatController(' . $code . ')' . "\n");
$codewriter->pushContext();
// Lets loop the iterator with a foreach construct
$codewriter->doForeach('$ctx->' . $varName, $this->var . '->' . $varName);
}
示例2: before
public function before(PHPTAL_Php_CodeWriter $codewriter)
{
$expressions = $codewriter->splitExpression($this->expression);
$definesAnyNonGlobalVars = false;
foreach ($expressions as $exp) {
list($defineScope, $defineVar, $expression) = $this->parseExpression($exp);
if (!$defineVar) {
continue;
}
$this->_defineScope = $defineScope;
if ($defineScope != 'global') {
$definesAnyNonGlobalVars = true;
}
// <span tal:define="global foo" /> should be invisible, but <img tal:define="bar baz" /> not
if ($this->_defineScope != 'global' && !$this->_pushedContext) {
$codewriter->pushContext();
$this->_pushedContext = true;
}
$this->_defineVar = $defineVar;
if ($expression === null) {
// no expression give, use content of tag as value for newly defined
// var.
$this->bufferizeContent($codewriter);
continue;
}
$code = $codewriter->evaluateExpression($expression);
if (is_array($code)) {
$this->chainedDefine($codewriter, $code);
} elseif ($code == PHPTAL_Php_TalesInternal::NOTHING_KEYWORD) {
$this->doDefineVarWith($codewriter, 'null');
} else {
$this->doDefineVarWith($codewriter, $code);
}
}
// if the content of the tag was buffered or the tag has nothing to tell, we hide it.
if ($this->_buffered || !$definesAnyNonGlobalVars && !$this->phpelement->hasRealContent() && !$this->phpelement->hasRealAttributes()) {
$this->phpelement->hidden = true;
}
}