public Renderer::renderRoot(&$elements)
Renders final HTML given a structured array tree.
Calls ::render() in such a way that placeholders are replaced.
Should therefore only be used in occasions where the final rendering is happening, just before sending a Response:
(Cannot be executed within another render context.)
array $elements: The structured array describing the data to be rendered.
\Drupal\Component\Render\MarkupInterface The rendered HTML.
\LogicException When called from inside another renderRoot() call.
Overrides RendererInterface::renderRoot
\Drupal\Core\Render\RendererInterface::render()
public function renderRoot(&$elements) { // Disallow calling ::renderRoot() from within another ::renderRoot() call. if ($this->isRenderingRoot) { $this->isRenderingRoot = FALSE; throw new \LogicException('A stray renderRoot() invocation is causing bubbling of attached assets to break.'); } // Render in its own render context. $this->isRenderingRoot = TRUE; $output = $this->executeInRenderContext(new RenderContext(), function() use (&$elements) { return $this->render($elements, TRUE); }); $this->isRenderingRoot = FALSE; return $output; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Renderer.php/function/Renderer::renderRoot/8.1.x