function DisplayPluginBase::calculateCacheMetadata

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::calculateCacheMetadata()
  2. 8.9.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::calculateCacheMetadata()
  3. 11.x core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::calculateCacheMetadata()

Overrides DisplayPluginInterface::calculateCacheMetadata

1 call to DisplayPluginBase::calculateCacheMetadata()
DisplayPluginBase::getCacheMetadata in core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
Gets the cache metadata.

File

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

Class

DisplayPluginBase
Base class for views display plugins.

Namespace

Drupal\views\Plugin\views\display

Code

public function calculateCacheMetadata() {
    $cache_metadata = new CacheableMetadata();
    // Iterate over ordinary views plugins.
    foreach (Views::getPluginTypes('plugin') as $plugin_type) {
        $plugin = $this->getPlugin($plugin_type);
        if ($plugin instanceof CacheableDependencyInterface) {
            $cache_metadata = $cache_metadata->merge(CacheableMetadata::createFromObject($plugin));
        }
    }
    // Iterate over all handlers. Note that at least the argument handler will
    // need to ask all its subplugins.
    foreach (array_keys(Views::getHandlerTypes()) as $handler_type) {
        $handlers = $this->getHandlers($handler_type);
        foreach ($handlers as $handler) {
            if ($handler instanceof CacheableDependencyInterface) {
                $cache_metadata = $cache_metadata->merge(CacheableMetadata::createFromObject($handler));
            }
        }
    }
    
    /** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache_plugin */
    if ($cache_plugin = $this->getPlugin('cache')) {
        $cache_plugin->alterCacheMetadata($cache_metadata);
    }
    return $cache_metadata;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.