You are here

public function TeamAppPermissionProvider::buildPermissions in Apigee Edge 8

Builds permissions for the given entity type.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type.

Return value

array The permissions.

Overrides EntityPermissionProviderInterface::buildPermissions

File

modules/apigee_edge_teams/src/Entity/TeamAppPermissionProvider.php, line 44

Class

TeamAppPermissionProvider
Permission provider for Team App entities.

Namespace

Drupal\apigee_edge_teams\Entity

Code

public function buildPermissions(EntityTypeInterface $entity_type) {
  $permissions = [];
  $team_app_plural_label = $entity_type
    ->getPluralLabel();
  $permissions[static::MANAGE_TEAM_APPS_PERMISSION] = [
    'title' => $this
      ->t('Manage @type', [
      '@type' => $team_app_plural_label,
    ]),
    'description' => $this
      ->t('Allows to manage all @team_apps in the system.', [
      '@team_apps' => $team_app_plural_label,
    ]),
    'restrict access' => TRUE,
  ];
  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;
}