/** * Render a named block from the parent view. * * @param OutputBuffer $out * @param string $name Name of the block to be rendered. * * @throws \RuntimeException When no parent view is available. */ public function renderParentBlock(OutputBuffer $out, $name) { if ($this->getParent() === NULL) { throw new \RuntimeException('Cannot render parent block because no template is inherited'); } $this->parent->renderBlock($out, $name); }
/** * 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); }