protected function ChangeSingleOgMembershipRoleBase::getOgRoleLabels in Organic groups 8
Returns a list of OgRole labels.
Return value
array An associative array of labels, keyed by OgRole ID.
2 calls to ChangeSingleOgMembershipRoleBase::getOgRoleLabels()
- ChangeSingleOgMembershipRoleBase::buildConfigurationForm in src/
Plugin/ Action/ ChangeSingleOgMembershipRoleBase.php - Form constructor.
- ChangeSingleOgMembershipRoleBase::defaultConfiguration in src/
Plugin/ Action/ ChangeSingleOgMembershipRoleBase.php - Gets default configuration for this plugin.
File
- src/
Plugin/ Action/ ChangeSingleOgMembershipRoleBase.php, line 122
Class
- ChangeSingleOgMembershipRoleBase
- Provides a base class for operations to change a user's group membership.
Namespace
Drupal\og\Plugin\ActionCode
protected function getOgRoleLabels() {
/** @var \Drupal\og\OgRoleInterface[] $roles */
$roles = OgRole::loadMultiple();
// Do not return the default roles 'member' and 'non-member'. These are
// required and cannot be added to or removed from a membership.
$role_names = [];
foreach ($roles as $role) {
if (!$role
->isRequired()) {
$role_names[$role
->getName()] = $role
->label();
}
}
return $role_names;
}