You are here

public function ServerListBuilder::getDefaultOperations in GraphQL 8.4

Gets this list's default operations.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the operations are for.

Return value

array The array structure is identical to the return value of self::getOperations().

Overrides ConfigEntityListBuilder::getDefaultOperations

File

src/Controller/ServerListBuilder.php, line 39

Class

ServerListBuilder
Admin page controller that shows the list of configured GraphQL servers.

Namespace

Drupal\graphql\Controller

Code

public function getDefaultOperations(EntityInterface $entity) {
  $operations = parent::getDefaultOperations($entity);
  $id = $entity
    ->id();
  if (\Drupal::currentUser()
    ->hasPermission('use graphql explorer')) {
    $operations['explorer'] = [
      'title' => 'Explorer',
      'weight' => 10,
      'url' => Url::fromRoute('graphql.explorer', [
        'graphql_server' => $id,
      ]),
    ];
  }
  if (\Drupal::currentUser()
    ->hasPermission('use graphql voyager')) {
    $operations['voyager'] = [
      'title' => 'Voyager',
      'weight' => 10,
      'url' => Url::fromRoute('graphql.voyager', [
        'graphql_server' => $id,
      ]),
    ];
  }
  if (\Drupal::currentUser()
    ->hasPermission("administer graphql configuration")) {
    $operations['persisted_queries'] = [
      'title' => 'Persisted queries',
      'weight' => 10,
      'url' => Url::fromRoute('entity.graphql_server.persisted_queries_form', [
        'graphql_server' => $id,
      ]),
    ];
  }
  return $operations;
}