W3cubDocs

/Drupal 8

public static function BubbleableMetadata::createFromRenderArray

public static BubbleableMetadata::createFromRenderArray(array $build)

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

Parameters

array $build: A render array.

Return value

static

Overrides CacheableMetadata::createFromRenderArray

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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!BubbleableMetadata.php/function/BubbleableMetadata::createFromRenderArray/8.1.x