You are here

protected static function OgMembership::invalidateTagsOnDelete in Organic groups 8

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.

Overrides EntityBase::invalidateTagsOnDelete

File

src/Entity/OgMembership.php, line 536

Class

OgMembership
The membership entity that connects a group and a user.

Namespace

Drupal\og\Entity

Code

protected static function invalidateTagsOnDelete(EntityTypeInterface $entity_type, array $entities) {
  parent::invalidateTagsOnDelete($entity_type, $entities);

  // A membership was deleted: invalidate the list cache tags of its group
  // membership lists, so that any lists that contain the membership will be
  // recalculated.
  $tags = [];
  foreach ($entities as $entity) {
    if ($group = $entity
      ->getGroup()) {
      $tags = Cache::mergeTags(Cache::buildTags(OgMembershipInterface::GROUP_MEMBERSHIP_LIST_CACHE_TAG_PREFIX, $group
        ->getCacheTagsToInvalidate()), $tags);
    }
  }
  Cache::invalidateTags($tags);
}