class AccessPermissions in Role Access Control 8.2
Same name and namespace in other branches
- 8 src/AccessPermissions.php \Drupal\rac\AccessPermissions
 
Permissions generation Role Access grants.
Hierarchy
- class \Drupal\rac\AccessPermissions uses StringTranslationTrait
 
Expanded class hierarchy of AccessPermissions
File
- src/
AccessPermissions.php, line 10  
Namespace
Drupal\racView source
class AccessPermissions {
  use StringTranslationTrait;
  /**
   * Returns an array of role access permissions.
   *
   * @return array
   *   A list of generated permissions.
   */
  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;
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            AccessPermissions:: | 
                  public | function | Returns an array of role access permissions. | |
| 
            StringTranslationTrait:: | 
                  protected | property | The string translation service. | 1 | 
| 
            StringTranslationTrait:: | 
                  protected | function | Formats a string containing a count of items. | |
| 
            StringTranslationTrait:: | 
                  protected | function | Returns the number of plurals supported by a given language. | |
| 
            StringTranslationTrait:: | 
                  protected | function | Gets the string translation service. | |
| 
            StringTranslationTrait:: | 
                  public | function | Sets the string translation service to use. | 2 | 
| 
            StringTranslationTrait:: | 
                  protected | function | Translates a string to the current language or to a given language. |