You are here

public function PermissionGenerator::rolePermissions in Role Delegation 8

Returns an array of permissions to assign specific roles.

Return value

array An array of permissions in the correct format for permission_callbacks.

File

src/PermissionGenerator.php, line 37

Class

PermissionGenerator
The PermissionGenerator class.

Namespace

Drupal\role_delegation

Code

public function rolePermissions() {
  $permissions = [];
  foreach ($this->delegatableRoles
    ->getAllRoles() as $rid => $role) {
    $permissions[sprintf('assign %s role', $rid)] = [
      'title' => $this
        ->t('Assign %role role', [
        '%role' => $role
          ->label(),
      ]),
    ];
  }
  return $permissions;
}