You are here

public function DisplayPluginBase::getCacheMetadata in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 2303
Contains \Drupal\views\Plugin\views\display\DisplayPluginBase.

Class

DisplayPluginBase
Base class for views display plugins.

Namespace

Drupal\views\Plugin\views\display

Code

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;
}