protected function TwigExtension::bubbleArgMetadata in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Template/TwigExtension.php \Drupal\Core\Template\TwigExtension::bubbleArgMetadata()
- 9 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()
File
- core/
lib/ Drupal/ Core/ Template/ TwigExtension.php, line 493
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);
}