public static CacheableMetadata::createFromRenderArray(array $build)
Creates a CacheableMetadata object with values taken from a render array.
array $build: A render array.
static
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; }
© 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!Cache!CacheableMetadata.php/function/CacheableMetadata::createFromRenderArray/8.1.x