public static CacheableMetadata::createFromRenderArray(array $build)
Creates a CacheableMetadata object with values taken from a render array.
Parameters
array $build: A render array.
Return value
static
File
- core/lib/Drupal/Core/Cache/CacheableMetadata.php, line 149
Class
- CacheableMetadata
- Defines a generic class for passing cacheability metadata.
Namespace
Drupal\Core\Cache
Code
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; }
Please login to continue.