You are here

public function GroupRole::invalidateTypeCache in Group 7

Invalidate the parent group type's GroupRole cache.

GroupType entities keep an internal cache of associated GroupRole entities. When saving or deleting a GroupRole, we need to invalidate said cache to ensure we do not work with outdated lists.

File

classes/group_role.inc, line 19
Defines the Entity API class for group roles.

Class

GroupRole
Main class for group role entities.

Code

public function invalidateTypeCache() {

  // Only invalidate the parent type's cache for local roles.
  if (empty($this->global)) {

    // If the type cannot be loaded, it should mean that this function was
    // run while we are still building an imported type. We therefore do not
    // need to invalidate the cache.
    if ($group_type = group_type_load($this->type)) {
      $group_type
        ->resetCache();
    }
  }
  else {
    foreach (group_types() as $group_type) {
      $group_type
        ->resetCache();
    }
  }
}