function Renderer::executeInRenderContext
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Render/Renderer.php \Drupal\Core\Render\Renderer::executeInRenderContext()
- 10 core/lib/Drupal/Core/Render/Renderer.php \Drupal\Core\Render\Renderer::executeInRenderContext()
- 11.x core/lib/Drupal/Core/Render/Renderer.php \Drupal\Core\Render\Renderer::executeInRenderContext()
Overrides RendererInterface::executeInRenderContext
2 calls to Renderer::executeInRenderContext()
- Renderer::renderPlain in core/
lib/ Drupal/ Core/ Render/ Renderer.php - Renders final HTML in situations where no assets are needed.
- Renderer::renderRoot in core/
lib/ Drupal/ Core/ Render/ Renderer.php - Renders final HTML given a structured array tree.
File
-
core/
lib/ Drupal/ Core/ Render/ Renderer.php, line 574
Class
- Renderer
- Turns a render array into an HTML string.
Namespace
Drupal\Core\RenderCode
public function executeInRenderContext(RenderContext $context, callable $callable) {
// Store the current render context.
$previous_context = $this->getCurrentRenderContext();
// Set the provided context and call the callable, it will use that context.
$this->setCurrentRenderContext($context);
$result = $callable();
// @todo Convert to an assertion in https://www.drupal.org/node/2408013
if ($context->count() > 1) {
throw new \LogicException('Bubbling failed.');
}
// Restore the original render context.
$this->setCurrentRenderContext($previous_context);
return $result;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.