You are here

public function Permissions::eventProxyRolePermissions in RNG - Events and Registrations 8.2

Same name and namespace in other branches
  1. 8 src/Permissions.php \Drupal\rng\Permissions::eventProxyRolePermissions()
  2. 3.x src/Permissions.php \Drupal\rng\Permissions::eventProxyRolePermissions()

Define permissions for proxy registrations by role.

Return value

array

1 string reference to 'Permissions::eventProxyRolePermissions'
rng.permissions.yml in ./rng.permissions.yml
rng.permissions.yml

File

src/Permissions.php, line 21

Class

Permissions
Define a permission generator.

Namespace

Drupal\rng

Code

public function eventProxyRolePermissions() {
  $permissions = [];
  $permissions['rng register self'] = [
    'title' => $this
      ->t('Register self'),
    'description' => $this
      ->t('Can register the logged-in user.'),
  ];
  foreach (user_roles(TRUE) as $role) {
    $role_id = $role
      ->id();
    $t_args = [
      '%role_name' => $role
        ->label(),
    ];
    $permissions["rng register role {$role_id}"] = [
      'title' => $this
        ->t('Register users with role: %role_name', $t_args),
      'description' => $this
        ->t('Can register other users with this role.'),
    ];
  }
  return $permissions;
}