You are here

public function OgRoleManager::getRequiredDefaultRoles in Organic groups 8

Returns the roles which every group type requires.

This provides the 'member' and 'non-member' roles. These are hard coded because they are strictly required and should not be altered.

Return value

\Drupal\og\Entity\OgRole[] An associative array of (unsaved) required OgRole entities, keyed by role name. These are populated with the basic properties: name, label and role_type.

Overrides OgRoleManagerInterface::getRequiredDefaultRoles

1 call to OgRoleManager::getRequiredDefaultRoles()
OgRoleManager::getDefaultRoles in src/OgRoleManager.php
Returns the default roles.

File

src/OgRoleManager.php, line 103

Class

OgRoleManager
Defines a manager of an OG role.

Namespace

Drupal\og

Code

public function getRequiredDefaultRoles() {
  $roles = [];
  $role_properties = [
    [
      'role_type' => OgRoleInterface::ROLE_TYPE_REQUIRED,
      'label' => 'Non-member',
      'name' => OgRoleInterface::ANONYMOUS,
    ],
    [
      'role_type' => OgRoleInterface::ROLE_TYPE_REQUIRED,
      'label' => 'Member',
      'name' => OgRoleInterface::AUTHENTICATED,
    ],
  ];
  foreach ($role_properties as $properties) {
    $roles[$properties['name']] = $this
      ->ogRoleStorage()
      ->create($properties);
  }
  return $roles;
}