public function OgMembership::getRoles in Organic groups 8
Gets all the referenced OG roles.
Return value
\Drupal\og\OgRoleInterface[] List of OG roles the user own for the current membership instance.
Overrides OgMembershipInterface::getRoles
4 calls to OgMembership::getRoles()
- OgMembership::addRole in src/
Entity/ OgMembership.php - Adds a role to the user membership.
- OgMembership::hasPermission in src/
Entity/ OgMembership.php - Checks if the user has a permission inside the group.
- OgMembership::preSave in src/
Entity/ OgMembership.php - Acts on an entity before the presave hook is invoked.
- OgMembership::revokeRoleById in src/
Entity/ OgMembership.php - Revokes a role from the OG membership.
File
- src/
Entity/ OgMembership.php, line 265
Class
- OgMembership
- The membership entity that connects a group and a user.
Namespace
Drupal\og\EntityCode
public function getRoles() : array {
$roles = [];
// Add the member role. This is only possible if a group has been set on the
// membership.
if ($this
->hasGroup()) {
$roles = [
OgRole::getRole($this
->getGroupEntityType(), $this
->getGroupBundle(), OgRoleInterface::AUTHENTICATED),
];
}
$roles = array_merge($roles, $this
->get('roles')
->referencedEntities());
return $roles;
}