/** * Bind to the given view model and render contents of the compiled view. * * @param OutputBuffer $out * @param ViewModelInterface $model * @param array<string, mixed> $params * @return OutputBuffer $out */ public final function render(OutputBuffer $out, ViewModelInterface $model, array $params = []) { $this->context->bind($model); $this->context->set('@view', $this); foreach ($params as $k => $v) { $this->context->set($k, $v); } try { if ($this->getParent() === NULL) { $this->renderMain($out); } else { $this->parent->renderMain($out); } return $out; } finally { $this->parent = false; $this->context->unbind(); } }
/** * Render contents of block taking blocks from the decorator into consideration. * * @param OutputBuffer $out * @param string $name The name of the block to be rendered. */ public function renderBlock(OutputBuffer $out, $name) { if (array_key_exists($name, $this->blocks)) { $pblock = $this->outerContext->set('@block', $name); $pout = $this->outerContext->set('@out', $out); $pthis = $this->outerContext->set('@this', $this); try { $this->blocks[$name]($out); return; } finally { $this->outerContext->set('@block', $pblock); $this->outerContext->set('@out', $pout); $this->outerContext->set('@this', $pthis); } } return parent::renderBlock($out, $name); }
public function bindContext(ExpressContext $context) { $this->expressContext = $context; $this->expressionContext = $context->getExpressionContext(); }