You are here

public function OgRoleManager::getDefaultRoles in Organic groups 8

Returns the default roles.

Return value

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

Overrides OgRoleManagerInterface::getDefaultRoles

1 call to OgRoleManager::getDefaultRoles()
OgRoleManager::createPerBundleRoles in src/OgRoleManager.php
Creates the roles for the given group type, based on the default roles.

File

src/OgRoleManager.php, line 86

Class

OgRoleManager
Defines a manager of an OG role.

Namespace

Drupal\og

Code

public function getDefaultRoles() {

  // Provide the required default roles: 'member' and 'non-member'.
  $roles = $this
    ->getRequiredDefaultRoles();
  $event = new DefaultRoleEvent();
  $this->eventDispatcher
    ->dispatch(DefaultRoleEventInterface::EVENT_NAME, $event);

  // Use the array union operator '+=' to ensure the default roles cannot be
  // altered by event subscribers.
  $roles += $event
    ->getRoles();
  return $roles;
}