Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/EntityBase.php \Drupal\Core\Entity\EntityBase::getCacheTagsToInvalidate()
  2. 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.
1 method overrides EntityBase::getCacheTagsToInvalidate()
ConfigEntityBase::getCacheTagsToInvalidate in core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
Returns the cache tags that should be used to invalidate caches.

File

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

Class

EntityBase
Defines a base entity class.

Namespace

Drupal\Core\Entity

Code

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