function BubbleableMetadata::createFromRenderArray

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

Creates a bubbleable metadata object with values taken from a render array.

Parameters

array $build: A render array.

Return value

static

Overrides CacheableMetadata::createFromRenderArray

8 calls to BubbleableMetadata::createFromRenderArray()
BubbleableMetadataTest::testCreateFromRenderArray in core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php
@covers ::createFromRenderArray @dataProvider providerTestCreateFromRenderArray
EntityField::getItems in core/modules/views/src/Plugin/views/field/EntityField.php
Gets an array of items for the field.
FormElementBase::processAutocomplete in core/lib/Drupal/Core/Render/Element/FormElementBase.php
Adds autocomplete functionality to elements.
HtmlResponseAttachmentsProcessor::renderPlaceholders in core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
Renders placeholders (#attached['placeholders']).
MediaEmbed::renderIntoDomNode in core/modules/media/src/Plugin/Filter/MediaEmbed.php
Renders the given render array into the given DOM node.

... See full list

File

core/lib/Drupal/Core/Render/BubbleableMetadata.php, line 65

Class

BubbleableMetadata
Value object used for bubbleable rendering metadata.

Namespace

Drupal\Core\Render

Code

public static function createFromRenderArray(array $build) {
    $meta = parent::createFromRenderArray($build);
    $meta->attachments = isset($build['#attached']) ? $build['#attached'] : [];
    return $meta;
}

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