function RenderContext::bubble

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

Bubbles the stack.

Whenever another level in the render array has been rendered, the stack must be bubbled, to merge its rendering metadata with that of the parent element.

File

core/lib/Drupal/Core/Render/RenderContext.php, line 41

Class

RenderContext
The render context: a stack containing bubbleable rendering metadata.

Namespace

Drupal\Core\Render

Code

public function bubble() {
    // If there's only one frame on the stack, then this is the root call, and
    // we can't bubble up further. ::renderRoot() will reset the stack, but we
    // must not reset it here to allow users of ::executeInRenderContext() to
    // access the stack directly.
    if ($this->count() === 1) {
        return;
    }
    // Merge the current and the parent stack frame.
    $current = $this->pop();
    $parent = $this->pop();
    $this->push($current->merge($parent));
}

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