public function GroupMembership::grantRoles in Group 7
Grant roles to a membership.
This is merely a helper function that sets the 'roles' property and then saves the GroupMembership. The actual business logic can be found in GroupMembershipController::save().
Parameters
array $roles: A list of role names to grant.
See also
GroupMembershipController::save()
File
- classes/
group_membership.inc, line 44 - Defines the Entity API class for group memberships.
Class
- GroupMembership
- Main class for group memberships.
Code
public function grantRoles(array $roles) {
// Update the membership's roles property.
$this->roles = array_merge($this->roles, $roles);
// Save the membership so the roles are actually granted.
$this
->save();
}