You are here

public function GroupTypeController::save in Group 7

Save a group type.

Overrides EntityAPIControllerExportable::save

See also

EntityAPIController::save()

File

classes/group_type.controller.inc, line 68
Defines the Entity API CRUD class for group types.

Class

GroupTypeController
Controller for group type entities.

Code

public function save($group_type, DatabaseTransaction $transaction = NULL) {

  // When we are dealing with an imported Group Type, we need to take care
  // of the Group Role entities that were imported along with it.
  if (!empty($group_type->is_new) && !empty($group_type->roles)) {

    // Create the group roles that were imported along with the type.
    foreach ($group_type->roles as $role) {
      $group_role = entity_import('group_role', entity_var_json_export($role));
      $group_role
        ->save();
    }

    // Remove the roles property before saving the group type.
    unset($group_type->roles);
  }

  // Save the group type after manipulating the roles and permissions
  // so that those functions don't incorrectly flag this group type
  // as ENTITY_CUSTOM.
  $return = parent::save($group_type, $transaction);

  // Rebuild the menu cache so the group/add page works.
  menu_rebuild();

  // Add Internationalization module support.
  if (module_exists('i18n_string')) {
    i18n_string_object_update('group_type', $group_type);
  }
  return $return;
}