8.3.x Entity.php protected static Entity::invalidateTagsOnDelete(EntityTypeInterface $entity_type, array $entities)
8.0.x Entity.php protected static Entity::invalidateTagsOnDelete(EntityTypeInterface $entity_type, array $entities)
8.1.x Entity.php protected static Entity::invalidateTagsOnDelete(EntityTypeInterface $entity_type, array $entities)
8.2.x Entity.php protected static Entity::invalidateTagsOnDelete(EntityTypeInterface $entity_type, array $entities)
8.4.x Entity.php protected static Entity::invalidateTagsOnDelete(EntityTypeInterface $entity_type, array $entities)

Invalidates an entity's cache tags upon delete.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.

\Drupal\Core\Entity\EntityInterface[] $entities: An array of entities.

1 call to Entity::invalidateTagsOnDelete()
Entity::postDelete in core/lib/Drupal/Core/Entity/Entity.php
Acts on deleted entities before the delete hook is invoked.
1 method overrides Entity::invalidateTagsOnDelete()
ConfigEntityBase::invalidateTagsOnDelete in core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
Override to never invalidate the individual entities' cache tags; the config system already invalidates them.

File

core/lib/Drupal/Core/Entity/Entity.php, line 549

Class

Entity
Defines a base entity class.

Namespace

Drupal\Core\Entity

Code

protected static function invalidateTagsOnDelete(EntityTypeInterface $entity_type, array $entities) {
  $tags = $entity_type->getListCacheTags();
  foreach ($entities as $entity) {
    // An entity was deleted: invalidate its own cache tag, but also its list
    // cache tags. (A deleted entity may cause changes in a paged list on
    // other pages than the one it's on. The one it's on is handled by its own
    // cache tag, but subsequent list pages would not be invalidated, hence we
    // must invalidate its list cache tags as well.)
    $tags = Cache::mergeTags($tags, $entity->getCacheTagsToInvalidate());
  }
  Cache::invalidateTags($tags);
}