You are here

public function ContentEntity::getListCacheContexts in Search API 8

Returns the list cache contexts associated with this datasource.

List cache contexts ensure that if items from a datasource are included in a list that any caches containing this list are varied as necessary. For example a view might contain a number of items from this datasource that are visible only by users that have a certain role. These list cache contexts will ensure that separate cached versions exist for users with this role and without it. These contexts should be included whenever a list is rendered that contains items from this datasource.

Return value

string[] The list cache contexts associated with this datasource.

Overrides DatasourcePluginBase::getListCacheContexts

File

src/Plugin/search_api/datasource/ContentEntity.php, line 1244

Class

ContentEntity
Represents a datasource which exposes the content entities.

Namespace

Drupal\search_api\Plugin\search_api\datasource

Code

public function getListCacheContexts() {
  $contexts = parent::getListCacheContexts();
  $entity_list_contexts = $this
    ->getEntityType()
    ->getListCacheContexts();
  return Cache::mergeContexts($entity_list_contexts, $contexts);
}