You are here

final class DefaultTeamPermissionsProvider in Apigee Edge 8

Provides the default team permissions.

Hierarchy

Expanded class hierarchy of DefaultTeamPermissionsProvider

1 string reference to 'DefaultTeamPermissionsProvider'
apigee_edge_teams.team_permissions.yml in modules/apigee_edge_teams/apigee_edge_teams.team_permissions.yml
modules/apigee_edge_teams/apigee_edge_teams.team_permissions.yml

File

modules/apigee_edge_teams/src/DefaultTeamPermissionsProvider.php, line 32

Namespace

Drupal\apigee_edge_teams
View source
final class DefaultTeamPermissionsProvider implements DynamicTeamPermissionProviderInterface, ContainerInjectionInterface {
  use StringTranslationTrait;

  /**
   * DefaultTeamPermissionsProvider constructor.
   *
   * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
   *   String translation.
   */
  public function __construct(TranslationInterface $string_translation) {
    $this->stringTranslation = $string_translation;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('string_translation'));
  }

  /**
   * {@inheritdoc}
   */
  public function permissions() : array {
    $permissions = [];
    $operations = [
      'team' => [
        'label' => $this
          ->t('Team'),
        'permissions' => [
          'manage_members' => [
            'label' => $this
              ->t('Manage team members and invitations'),
            'description' => $this
              ->t('Add/remove team members and administer team invitations.'),
          ],
        ],
      ],
      'team_app' => [
        'label' => $this
          ->t('Team apps'),
        'permissions' => [
          'view' => $this
            ->t('View Team Apps'),
          'create' => $this
            ->t('Create Team Apps'),
          'update' => $this
            ->t('Edit any Team Apps'),
          'delete' => $this
            ->t('Delete any Team Apps'),
          'analytics' => $this
            ->t('View analytics of any Team Apps'),
          'add_api_key' => $this
            ->t('Add API key to Team Apps'),
          'revoke_api_key' => $this
            ->t('Revoke API key from Team Apps'),
          'delete_api_key' => $this
            ->t('Delete API key from Team Apps'),
          'edit_api_products' => $this
            ->t('Edit API products for Team Apps'),
        ],
      ],
      'api_product' => [
        'label' => $this
          ->t('API products'),
        'permissions' => [
          'access_public' => $this
            ->t('View and assign public API products to team apps'),
          'access_private' => $this
            ->t('View and assign private API products to team apps'),
          'access_internal' => $this
            ->t('View and assign internal API products to team apps'),
        ],
      ],
    ];
    foreach ($operations as $group => $group_def) {
      foreach ($group_def['permissions'] as $operation => $operation_def) {
        $description = NULL;
        if (is_array($operation_def)) {
          $label = $operation_def['label'];
          $description = $operation_def['description'] ?? NULL;
        }
        else {
          $label = $operation_def;
        }
        $name = "{$group}_{$operation}";
        $permissions[$name] = new TeamPermission($name, $label, $group_def['label'], $description);
      }
    }
    return $permissions;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DefaultTeamPermissionsProvider::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
DefaultTeamPermissionsProvider::permissions public function Returns team permissions provided by a module. Overrides DynamicTeamPermissionProviderInterface::permissions
DefaultTeamPermissionsProvider::__construct public function DefaultTeamPermissionsProvider constructor.
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.