You are here

public function SearchApiTagCache::alterCacheMetadata in Search API 8

Alters the cache metadata of a display upon saving a view.

Parameters

\Drupal\Core\Cache\CacheableMetadata $cache_metadata: The cache metadata.

Overrides CachePluginBase::alterCacheMetadata

File

src/Plugin/views/cache/SearchApiTagCache.php, line 122

Class

SearchApiTagCache
Defines a tag-based cache plugin for use with Search API views.

Namespace

Drupal\search_api\Plugin\views\cache

Code

public function alterCacheMetadata(CacheableMetadata $cache_metadata) {

  // Allow modules that alter the query to add their cache metadata to the
  // view.
  $query = $this
    ->getQuery()
    ->getSearchApiQuery();
  $query
    ->preExecute();
  $cache_metadata
    ->addCacheableDependency($query);
}