function RenderContext::update

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

Updates the current frame of the stack.

Parameters

array &$element: The element of the render array that has just been rendered. The stack frame for this element will be updated with the bubbleable rendering metadata of this element.

File

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

Class

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

Namespace

Drupal\Core\Render

Code

public function update(&$element) {
    // The latest frame represents the bubbleable metadata for the subtree.
    $frame = $this->pop();
    // Update the frame, but also update the current element, to ensure it
    // contains up-to-date information in case it gets render cached.
    $updated_frame = BubbleableMetadata::createFromRenderArray($element)->merge($frame);
    $updated_frame->applyTo($element);
    $this->push($updated_frame);
}

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