You are here

protected function SqlGroupGraphStorage::invalidate in Subgroup (Graph) 1.0.x

Invalidate the cache tags for the groups provided.

2 calls to SqlGroupGraphStorage::invalidate()
SqlGroupGraphStorage::addEdge in src/Graph/SqlGroupGraphStorage.php
Relates the parent group and the child group.
SqlGroupGraphStorage::removeEdge in src/Graph/SqlGroupGraphStorage.php
Removes the relationship between the parent group and the child group.

File

src/Graph/SqlGroupGraphStorage.php, line 76

Class

SqlGroupGraphStorage
SQL based storage of the group relationship graph.

Namespace

Drupal\ggroup\Graph

Code

protected function invalidate($gids) {
  if (!empty($gids)) {

    // Create a cache tag for all the groups passed in.
    foreach ($gids as $gid) {
      $cache_tags[] = "group:{$gid}";

      // @TODO: Should the cache be actively rebuilt instead?
      // Indicate that this group needs to be reloaded.
      $this->loaded[$gid] = FALSE;

      // Remove all the values for this group since the values are no longer
      // considered valid.
      unset($this->ancestors[$gid]);
      unset($this->descendants[$gid]);
      unset($this->directAncestors[$gid]);
      unset($this->directDescendants[$gid]);
    }

    // And invalidate the tags.
    if (!empty($cache_tags)) {
      Cache::invalidateTags($cache_tags);
    }
  }
}