You are here

final class TeamPermissionProvider in Apigee Edge 8

Permission provider for Team entities.

Hierarchy

Expanded class hierarchy of TeamPermissionProvider

File

modules/apigee_edge_teams/src/Entity/TeamPermissionProvider.php, line 30

Namespace

Drupal\apigee_edge_teams\Entity
View source
final class TeamPermissionProvider implements EntityPermissionProviderInterface {
  use StringTranslationTrait;

  /**
   * {@inheritdoc}
   */
  public function buildPermissions(EntityTypeInterface $entity_type) {
    $permissions = [];
    $entity_type_id = $entity_type
      ->id();
    $singular_label = $entity_type
      ->getSingularLabel();
    $plural_label = $entity_type
      ->getPluralLabel();
    $permissions["administer {$entity_type_id}"] = [
      'title' => $this
        ->t('Administer @type', [
        '@type' => $plural_label,
      ]),
      'description' => $this
        ->t('Administer module configure and manage any team and team apps.'),
      'restrict access' => TRUE,
    ];
    $permissions["manage {$entity_type_id} members"] = [
      'title' => $this
        ->t('Manage @type members', [
        '@type' => $singular_label,
      ]),
      'restrict access' => TRUE,
    ];
    $permissions["view any {$entity_type_id}"] = [
      'title' => $this
        ->t('View any @type', [
        '@type' => $plural_label,
      ]),
    ];
    $permissions["create {$entity_type_id}"] = [
      'title' => $this
        ->t('Create @type', [
        '@type' => $plural_label,
      ]),
    ];
    $permissions["update any {$entity_type_id}"] = [
      'title' => $this
        ->t('Update any @type', [
        '@type' => $singular_label,
      ]),
    ];
    $permissions["delete any {$entity_type_id}"] = [
      'title' => $this
        ->t('Delete any @type', [
        '@type' => $singular_label,
      ]),
    ];
    foreach ($permissions as $name => $permission) {
      $permissions[$name]['provider'] = $entity_type
        ->getProvider();

      // TranslatableMarkup objects don't sort properly.
      $permissions[$name]['title'] = (string) $permission['title'];
    }
    return $permissions;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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.
TeamPermissionProvider::buildPermissions public function Builds permissions for the given entity type. Overrides EntityPermissionProviderInterface::buildPermissions