You are here

Permissions.php in RNG - Events and Registrations 8.2

Same filename and directory in other branches
  1. 8 src/Permissions.php
  2. 3.x src/Permissions.php

Namespace

Drupal\rng

File

src/Permissions.php
View source
<?php

namespace Drupal\rng;

use Drupal\Core\Routing\UrlGeneratorTrait;
use Drupal\Core\StringTranslation\StringTranslationTrait;

/**
 * Define a permission generator.
 */
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;
  }

}

Classes

Namesort descending Description
Permissions Define a permission generator.