public function DisplayPluginBase::getCacheMetadata in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::getCacheMetadata()
Gets the cache metadata.
Return value
\Drupal\Core\Cache\CacheableMetadata The cache metadata.
Overrides DisplayPluginInterface::getCacheMetadata
File
- core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php, line 2367
Class
- DisplayPluginBase
- Base class for views display plugins.
Namespace
Drupal\views\Plugin\views\displayCode
public function getCacheMetadata() {
if (!isset($this->display['cache_metadata'])) {
$cache_metadata = $this
->calculateCacheMetadata();
$this->display['cache_metadata']['max-age'] = $cache_metadata
->getCacheMaxAge();
$this->display['cache_metadata']['contexts'] = $cache_metadata
->getCacheContexts();
$this->display['cache_metadata']['tags'] = $cache_metadata
->getCacheTags();
}
else {
$cache_metadata = (new CacheableMetadata())
->setCacheMaxAge($this->display['cache_metadata']['max-age'])
->setCacheContexts($this->display['cache_metadata']['contexts'])
->setCacheTags($this->display['cache_metadata']['tags']);
}
return $cache_metadata;
}