function TwigExtension::bubbleArgMetadata
Same name in other branches
- 9 core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::bubbleArgMetadata()
- 8.9.x core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::bubbleArgMetadata()
- 11.x core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::bubbleArgMetadata()
Bubbles Twig template argument's cacheability & attachment metadata.
For example: a generated link or generated URL object is passed as a Twig template argument, and its bubbleable metadata must be bubbled.
Parameters
mixed $arg: A Twig template argument that is about to be printed.
See also
\Drupal\Core\Theme\ThemeManager::render()
\Drupal\Core\Render\RendererInterface::render()
2 calls to TwigExtension::bubbleArgMetadata()
- TwigExtension::escapeFilter in core/
lib/ Drupal/ Core/ Template/ TwigExtension.php - Overrides twig_escape_filter().
- TwigExtension::renderVar in core/
lib/ Drupal/ Core/ Template/ TwigExtension.php - Wrapper around render() for twig printed output.
File
-
core/
lib/ Drupal/ Core/ Template/ TwigExtension.php, line 502
Class
- TwigExtension
- A class providing Drupal Twig extensions.
Namespace
Drupal\Core\TemplateCode
protected function bubbleArgMetadata($arg) {
// If it's a renderable, then it'll be up to the generated render array it
// returns to contain the necessary cacheability & attachment metadata. If
// it doesn't implement CacheableDependencyInterface or AttachmentsInterface
// then there is nothing to do here.
if ($arg instanceof RenderableInterface || !($arg instanceof CacheableDependencyInterface || $arg instanceof AttachmentsInterface)) {
return;
}
$arg_bubbleable = [];
BubbleableMetadata::createFromObject($arg)->applyTo($arg_bubbleable);
$this->renderer
->render($arg_bubbleable);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.