public static function CacheableMetadata::createFromRenderArray in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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
13 calls to CacheableMetadata::createFromRenderArray()
- 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.
- CacheableMetadataTest::testCreateFromRenderArray in core/
tests/ Drupal/ Tests/ Core/ Cache/ CacheableMetadataTest.php - @covers ::createFromRenderArray @dataProvider providerTestCreateFromRenderArray
- EntityReferenceFormatterTest::testLabelFormatter in core/
modules/ field/ src/ Tests/ EntityReference/ EntityReferenceFormatterTest.php - Tests the label formatter.
- Feed::buildResponse in core/
modules/ views/ src/ Plugin/ views/ display/ Feed.php - Builds up a response with the rendered view as content.
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 154 - Contains \Drupal\Core\Cache\CacheableMetadata.
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;
}