You are here

class AccessPermissions in Role Access Control 8

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

Permissions generation Role Access grants.

Hierarchy

Expanded class hierarchy of AccessPermissions

File

src/AccessPermissions.php, line 10

Namespace

Drupal\rac
View 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

Namesort descending Modifiers Type Description Overrides
AccessPermissions::permissions public function Returns an array of role access permissions.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.