ServerListBuilder.php in GraphQL 8.4
File
src/Controller/ServerListBuilder.php
View source
<?php
namespace Drupal\graphql\Controller;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;
class ServerListBuilder extends ConfigEntityListBuilder {
public function buildHeader() {
return [
'label' => $this
->t('Label'),
] + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
return [
'label' => $entity
->label(),
] + parent::buildRow($entity);
}
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;
}
}
Classes
Name |
Description |
ServerListBuilder |
Admin page controller that shows the list of configured GraphQL servers. |