You are here

public function CachePluginBase::getCacheTags in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/cache/CachePluginBase.php \Drupal\views\Plugin\views\cache\CachePluginBase::getCacheTags()
  2. 9 core/modules/views/src/Plugin/views/cache/CachePluginBase.php \Drupal\views\Plugin\views\cache\CachePluginBase::getCacheTags()

Gets an array of cache tags for the current view.

Return value

string[] An array of cache tags based on the current view.

1 call to CachePluginBase::getCacheTags()
CachePluginBase::cacheSet in core/modules/views/src/Plugin/views/cache/CachePluginBase.php
Save data to the cache.

File

core/modules/views/src/Plugin/views/cache/CachePluginBase.php, line 238

Class

CachePluginBase
The base plugin to handle caching.

Namespace

Drupal\views\Plugin\views\cache

Code

public function getCacheTags() {
  $tags = $this->view->storage
    ->getCacheTags();

  // The list cache tags for the entity types listed in this view.
  $entity_information = $this->view
    ->getQuery()
    ->getEntityTableInfo();
  if (!empty($entity_information)) {

    // Add the list cache tags for each entity type used by this view.
    foreach ($entity_information as $metadata) {
      $tags = Cache::mergeTags($tags, \Drupal::entityTypeManager()
        ->getDefinition($metadata['entity_type'])
        ->getListCacheTags());
    }
  }
  $tags = Cache::mergeTags($tags, $this->view
    ->getQuery()
    ->getCacheTags());
  return $tags;
}