You are here

public function MasqueradePermissions::permissions in Masquerade 8.2

Returns an array of masquerade permissions.

@todo Allow permissions for each role to masquerade as as subset of roles https://drupal.org/node/1171500

Return value

array The permissions array.

1 string reference to 'MasqueradePermissions::permissions'
masquerade.permissions.yml in ./masquerade.permissions.yml
masquerade.permissions.yml

File

src/MasqueradePermissions.php, line 25

Class

MasqueradePermissions
Provides dynamic permissions of the masquerade module.

Namespace

Drupal\masquerade

Code

public function permissions() {
  $permissions = [];

  // Anonymous was intentionally left out. Logout instead.
  $roles = $this
    ->getUserRoles();
  foreach ($roles as $role) {
    $permissions['masquerade as ' . $role
      ->id()] = [
      'title' => $this
        ->t('Masquerade as @role', [
        '@role' => $role
          ->label(),
      ]),
      'restrict access' => TRUE,
    ];
  }
  return $permissions;
}