function CacheableMetadata::createFromRenderArray
Creates a CacheableMetadata object with values taken from a render array.
Parameters
array $build: A render array.
Return value
static
20 calls to CacheableMetadata::createFromRenderArray()
- BlockComponentRenderArray::onBuildRender in core/
modules/ layout_builder/ src/ EventSubscriber/ BlockComponentRenderArray.php - Builds render arrays for block plugins and sets it on the event.
- BlockPageVariant::build in core/
modules/ block/ src/ Plugin/ DisplayVariant/ BlockPageVariant.php - Builds and returns the renderable array for the display variant.
- BubbleableMetadata::createFromRenderArray in core/
lib/ Drupal/ Core/ Render/ BubbleableMetadata.php - Creates a bubbleable metadata object with values taken from a render array.
- BubbleableMetadata::createFromRenderArray in core/
lib/ Drupal/ Core/ Render/ BubbleableMetadata.php - Creates a bubbleable metadata object with values taken from a render array.
- ContentTranslationHooks::pageAttachments in core/
modules/ content_translation/ src/ Hook/ ContentTranslationHooks.php - Implements hook_page_attachments().
1 method overrides CacheableMetadata::createFromRenderArray()
- BubbleableMetadata::createFromRenderArray in core/
lib/ Drupal/ Core/ Render/ BubbleableMetadata.php - Creates a bubbleable metadata object with values taken from a render array.
File
-
core/
lib/ Drupal/ Core/ Cache/ CacheableMetadata.php, line 149
Class
- CacheableMetadata
- Defines a generic class for passing cacheability metadata.
Namespace
Drupal\Core\CacheCode
public static function createFromRenderArray(array $build) {
$meta = new static();
$meta->cacheContexts = isset($build['#cache']['contexts']) ? $build['#cache']['contexts'] : [];
$meta->cacheTags = isset($build['#cache']['tags']) ? $build['#cache']['tags'] : [];
$meta->cacheMaxAge = isset($build['#cache']['max-age']) ? $build['#cache']['max-age'] : Cache::PERMANENT;
return $meta;
}