You are here

public function EntityBase::getCacheTagsToInvalidate in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::getCacheTagsToInvalidate()

Returns the cache tags that should be used to invalidate caches.

This will not return additional cache tags added through addCacheTags().

Return value

string[] Set of cache tags.

Overrides EntityInterface::getCacheTagsToInvalidate

See also

\Drupal\Core\Cache\RefinableCacheableDependencyInterface::addCacheTags()

\Drupal\Core\Cache\CacheableDependencyInterface::getCacheTags()

2 calls to EntityBase::getCacheTagsToInvalidate()
EntityBase::getCacheTags in core/lib/Drupal/Core/Entity/EntityBase.php
The cache tags associated with this object.
EntityBase::invalidateTagsOnSave in core/lib/Drupal/Core/Entity/EntityBase.php
Invalidates an entity's cache tags upon save.
4 methods override EntityBase::getCacheTagsToInvalidate()
ConfigEntityBase::getCacheTagsToInvalidate in core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
Returns the cache tags that should be used to invalidate caches.
Item::getCacheTagsToInvalidate in core/modules/aggregator/src/Entity/Item.php
Returns the cache tags that should be used to invalidate caches.
PathAlias::getCacheTagsToInvalidate in core/modules/path_alias/src/Entity/PathAlias.php
Returns the cache tags that should be used to invalidate caches.
Shortcut::getCacheTagsToInvalidate in core/modules/shortcut/src/Entity/Shortcut.php
Returns the cache tags that should be used to invalidate caches.

File

core/lib/Drupal/Core/Entity/EntityBase.php, line 513

Class

EntityBase
Defines a base entity class.

Namespace

Drupal\Core\Entity

Code

public function getCacheTagsToInvalidate() {
  if ($this
    ->isNew()) {
    return [];
  }
  return [
    $this->entityTypeId . ':' . $this
      ->id(),
  ];
}