public function OgMembership::revokeRoleById in Organic groups 8
Revokes a role from the OG membership.
Parameters
string $role_id: The OG role ID.
Return value
\Drupal\og\OgMembershipInterface The updated OG Membership object.
Overrides OgMembershipInterface::revokeRoleById
1 call to OgMembership::revokeRoleById()
- OgMembership::revokeRole in src/
Entity/ OgMembership.php - Revokes a role from the OG membership.
File
- src/
Entity/ OgMembership.php, line 247
Class
- OgMembership
- The membership entity that connects a group and a user.
Namespace
Drupal\og\EntityCode
public function revokeRoleById(string $role_id) : OgMembershipInterface {
$roles = $this
->getRoles();
foreach ($roles as $key => $existing_role) {
if ($existing_role
->id() == $role_id) {
unset($roles[$key]);
// We can stop iterating.
break;
}
}
return $this
->setRoles($roles);
}