Entity::invalidateTagsOnDelete

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.

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);
}
doc_Drupal
2016-10-29 09:04:21
Comments
Leave a Comment

Please login to continue.