You are here

public function GroupMembershipController::save in Group 7

Save a group membership.

The saving of roles takes place in GroupMembershipController::invoke().

@todo Validation of added roles.

Overrides EntityAPIController::save

See also

GroupMembershipController::invoke()

File

classes/group_membership.controller.inc, line 135
Defines the Entity API CRUD class for group memberships.

Class

GroupMembershipController
Controller for group membership entities.

Code

public function save($group_membership, DatabaseTransaction $transaction = NULL) {
  if (!isset($group_membership->uid) || $group_membership->uid == 0) {
    throw new EntityMalformedException(t("Group memberships cannot be created for anonymous users."));
  }

  // Clean up the 'roles' property to avoid duplicates.
  $group_membership->roles = array_unique($group_membership->roles);
  return parent::save($group_membership, $transaction);
}