function CacheableMetadata::createFromRenderArray
Same name and namespace in other branches
- 8.9.x core/lib/Drupal/Core/Cache/CacheableMetadata.php \Drupal\Core\Cache\CacheableMetadata::createFromRenderArray()
- 10 core/lib/Drupal/Core/Cache/CacheableMetadata.php \Drupal\Core\Cache\CacheableMetadata::createFromRenderArray()
- 11.x core/lib/Drupal/Core/Cache/CacheableMetadata.php \Drupal\Core\Cache\CacheableMetadata::createFromRenderArray()
Creates a CacheableMetadata object with values taken from a render array.
Parameters
array $build: A render array.
Return value
static
4 calls to CacheableMetadata::createFromRenderArray()
- BubbleableMetadata::createFromRenderArray in core/
lib/ Drupal/ Core/ Render/ BubbleableMetadata.php - Creates a bubbleable metadata object with values taken from a render array.
- HtmlResponse::setContent in core/
lib/ Drupal/ Core/ Render/ HtmlResponse.php - Sets the response content.
- RenderCache::set in core/
lib/ Drupal/ Core/ Render/ RenderCache.php - Caches the rendered output of a renderable array.
- Renderer::addCacheableDependency in core/
lib/ Drupal/ Core/ Render/ Renderer.php - Adds a dependency on an object: merges its cacheability metadata.
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.