Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Renderer.php

function Renderer::renderRoot

Overrides RendererInterface::renderRoot

File

core/lib/Drupal/Core/Render/Renderer.php, line 98

Class

Renderer
Turns a render array into an HTML string.

Namespace

Drupal\Core\Render

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal