function MetadataBubblingUrlGenerator::bubble

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php \Drupal\Core\Render\MetadataBubblingUrlGenerator::bubble()
  2. 10 core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php \Drupal\Core\Render\MetadataBubblingUrlGenerator::bubble()
  3. 11.x core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php \Drupal\Core\Render\MetadataBubblingUrlGenerator::bubble()

Bubbles the bubbleable metadata to the current render context.

Parameters

\Drupal\Core\GeneratedUrl $generated_url: The generated URL whose bubbleable metadata to bubble.

array $options: (optional) The URL options. Defaults to none.

2 calls to MetadataBubblingUrlGenerator::bubble()
MetadataBubblingUrlGenerator::generate in core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php
MetadataBubblingUrlGenerator::generateFromRoute in core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php
Generates a URL or path for a specific route based on the given parameters.

File

core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php, line 79

Class

MetadataBubblingUrlGenerator
Decorator for the URL generator, which bubbles bubbleable URL metadata.

Namespace

Drupal\Core\Render

Code

protected function bubble(GeneratedUrl $generated_url, array $options = []) {
    // Bubbling metadata makes sense only if the code is executed inside a
    // render context. All code running outside controllers has no render
    // context by default, so URLs used there are not supposed to affect the
    // response cacheability.
    if ($this->renderer
        ->hasRenderContext()) {
        $build = [];
        $generated_url->applyTo($build);
        $this->renderer
            ->render($build);
    }
}

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