public RendererInterface::executeInRenderContext(RenderContext $context, callable $callable)
Executes a callable within a render context.
Only for very advanced use cases. Prefer using ::renderRoot() and ::renderPlain() instead.
All rendering must happen within a render context. Within a render context, all bubbleable metadata is bubbled and hence tracked. Outside of a render context, it would be lost. This could lead to missing assets, incorrect cache variations (and thus security issues), insufficient cache invalidations, and so on.
Any and all rendering must therefore happen within a render context, and it is this method that provides that.
\Drupal\Core\Render\RenderContext $context: The render context to execute the callable within.
callable $callable: The callable to execute.
mixed The callable's return value.
\LogicException In case bubbling has failed, can only happen in case of broken code.
\Drupal\Core\Render\RenderContext
\Drupal\Core\Render\BubbleableMetadata
public function executeInRenderContext(RenderContext $context, callable $callable);
© 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!RendererInterface.php/function/RendererInterface::executeInRenderContext/8.1.x