You are here

public function GroupRole::flagTypeCustom in Group 7

Flag the parent group type as ENTITY_CUSTOM.

If the group role belongs to a group type, the group type it belongs to will be flagged as ENTITY_CUSTOM.

File

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

Class

GroupRole
Main class for group role entities.

Code

public function flagTypeCustom() {

  // Only flag the parent type when we're dealing with a local group role.
  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. Furthermore, if the
    // group type can be loaded but has the 'is_deleted' property, it means
    // we were about to delete that group type. In both cases, we do not need
    // to save the group type.
    if (($group_type = group_type_load($this->type)) && empty($group_type->is_deleted)) {

      // Saving without $entity->is_rebuild automatically sets ENTITY_CUSTOM.
      $group_type
        ->save();
    }
  }
}