Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DisplayPluginBase.php

function DisplayPluginBase::getCacheMetadata

Overrides DisplayPluginInterface::getCacheMetadata

File

core/modules/views/src/Plugin/views/display/DisplayPluginBase.php, line 2400

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal