function Renderer::setCurrentRenderContext

Same name in other branches
  1. 9 core/lib/Drupal/Core/Render/Renderer.php \Drupal\Core\Render\Renderer::setCurrentRenderContext()
  2. 8.9.x core/lib/Drupal/Core/Render/Renderer.php \Drupal\Core\Render\Renderer::setCurrentRenderContext()
  3. 10 core/lib/Drupal/Core/Render/Renderer.php \Drupal\Core\Render\Renderer::setCurrentRenderContext()

Sets the current render context.

Parameters

\Drupal\Core\Render\RenderContext|null $context: The render context. This can be NULL for instance when restoring the original render context, which is in fact NULL.

Return value

$this

1 call to Renderer::setCurrentRenderContext()
Renderer::executeInRenderContext in core/lib/Drupal/Core/Render/Renderer.php
Executes a callable within a render context.

File

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

Class

Renderer
Turns a render array into an HTML string.

Namespace

Drupal\Core\Render

Code

protected function setCurrentRenderContext(?RenderContext $context = NULL) {
    $request = $this->requestStack
        ->getCurrentRequest();
    static::$contextCollection[$request] = $context;
    return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.