public function OgMembership::addRole in Organic groups 8
Adds a role to the user membership.
Parameters
\Drupal\og\OgRoleInterface $role: The OG role.
Return value
\Drupal\og\OgMembershipInterface The updated OG Membership object.
Overrides OgMembershipInterface::addRole
File
- src/
Entity/ OgMembership.php, line 230
Class
- OgMembership
- The membership entity that connects a group and a user.
Namespace
Drupal\og\EntityCode
public function addRole(OgRoleInterface $role) : OgMembershipInterface {
$roles = $this
->getRoles();
$roles[] = $role;
return $this
->setRoles($roles);
}