You are here

class Permissions in RNG - Events and Registrations 8

Same name and namespace in other branches
  1. 8.2 src/Permissions.php \Drupal\rng\Permissions
  2. 3.x src/Permissions.php \Drupal\rng\Permissions

Define a permission generator.

Hierarchy

Expanded class hierarchy of Permissions

File

src/Permissions.php, line 11

Namespace

Drupal\rng
View source
class Permissions {
  use StringTranslationTrait;
  use UrlGeneratorTrait;

  /**
   * Define permissions for proxy registrations by role.
   *
   * @return array
   */
  public function eventProxyRolePermissions() {
    $permissions = [];
    $permissions['rng register self'] = [
      'title' => $this
        ->t('Register self'),
      'description' => $this
        ->t('Can register the logged-in user.'),
    ];
    foreach (user_roles(TRUE) as $role) {
      $role_id = $role
        ->id();
      $t_args = [
        '%role_name' => $role
          ->label(),
      ];
      $permissions["rng register role {$role_id}"] = [
        'title' => $this
          ->t('Register users with role: %role_name', $t_args),
        'description' => $this
          ->t('Can register other users with this role.'),
      ];
    }
    return $permissions;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Permissions::eventProxyRolePermissions public function Define permissions for proxy registrations by role.
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.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::redirect Deprecated protected function Returns a redirect response object for the specified route. 3
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.