You are here

public function OgEventSubscriber::provideDefaultRoles in Organic groups 8

Provides a default role for the group administrator.

Parameters

\Drupal\og\Event\DefaultRoleEventInterface $event: The default role event.

File

src/EventSubscriber/OgEventSubscriber.php, line 237

Class

OgEventSubscriber
Event subscribers for Organic Groups.

Namespace

Drupal\og\EventSubscriber

Code

public function provideDefaultRoles(DefaultRoleEventInterface $event) {

  /** @var \Drupal\og\Entity\OgRole $role */
  $role = $this->entityTypeManager
    ->getStorage('og_role')
    ->create([
    'name' => OgRoleInterface::ADMINISTRATOR,
    'label' => 'Administrator',
    'is_admin' => TRUE,
  ]);
  $event
    ->addRole($role);
}