function DisplayPluginBase::calculateCacheMetadata
Calculates the display's cache metadata by inspecting each handler/plugin.
Return value
\Drupal\Core\Cache\CacheableMetadata The cache metadata.
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 2333 
Class
- DisplayPluginBase
- Base class for views display plugins.
Namespace
Drupal\views\Plugin\views\displayCode
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.
