You are here

protected function OgMembership::invalidateTagsOnSave in Organic groups 8

Invalidates an entity's cache tags upon save.

Parameters

bool $update: TRUE if the entity has been updated, or FALSE if it has been inserted.

Overrides EntityBase::invalidateTagsOnSave

File

src/Entity/OgMembership.php, line 518

Class

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

Namespace

Drupal\og\Entity

Code

protected function invalidateTagsOnSave($update) {
  parent::invalidateTagsOnSave($update);

  // A membership was created or updated: invalidate the membership list cache
  // tags of its group. An updated membership may start to appear in a group's
  // membership listings because it now meets those listings' filtering
  // requirements. A newly created membership may start to appear in listings
  // because it did not exist before.
  $group = $this
    ->getGroup();
  if (!empty($group)) {
    $tags = Cache::buildTags(OgMembershipInterface::GROUP_MEMBERSHIP_LIST_CACHE_TAG_PREFIX, $group
      ->getCacheTagsToInvalidate());
    Cache::invalidateTags($tags);
  }
}