You are here

public function AccessPermissions::permissions in Role Access Control 8

Same name and namespace in other branches
  1. 8.2 src/AccessPermissions.php \Drupal\rac\AccessPermissions::permissions()

Returns an array of role access permissions.

Return value

array A list of generated permissions.

1 string reference to 'AccessPermissions::permissions'
rac.permissions.yml in ./rac.permissions.yml
rac.permissions.yml

File

src/AccessPermissions.php, line 20

Class

AccessPermissions
Permissions generation Role Access grants.

Namespace

Drupal\rac

Code

public function permissions() {
  $ops = [
    'view',
    'update',
  ];
  $permissions = [];
  $roles = user_roles();
  foreach ($ops as $op) {
    foreach ($roles as $role) {
      $permission = "RAC_" . $op . "_" . $role
        ->id();
      $permissions[$permission] = [
        'title' => $this
          ->t("@op Content for Role @label", [
          '@op' => $op,
          '@label' => $role
            ->label(),
        ]),
        'restrict access' => TRUE,
      ];
    }
  }
  return $permissions;
}