class ExplorerController in GraphQL 8.2
Same name and namespace in other branches
- 8.4 src/Controller/ExplorerController.php \Drupal\graphql\Controller\ExplorerController
- 8 src/Controller/ExplorerController.php \Drupal\graphql\Controller\ExplorerController
- 8.3 src/Controller/ExplorerController.php \Drupal\graphql\Controller\ExplorerController
Controller for the GraphiQL query builder IDE.
Hierarchy
- class \Drupal\graphql\Controller\ExplorerController implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of ExplorerController
File
- src/
Controller/ ExplorerController.php, line 14
Namespace
Drupal\graphql\ControllerView source
class ExplorerController implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The URL generator service.
*
* @var \Drupal\Core\Routing\UrlGeneratorInterface
*/
protected $urlGenerator;
/**
* Constructs a ExplorerController object.
*
* @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
* The url generator service.
*/
public function __construct(UrlGeneratorInterface $url_generator) {
$this->urlGenerator = $url_generator;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('url_generator'));
}
/**
* Controller for the GraphiQL query builder IDE.
*
* @return array
* The render array.
*/
public function viewExplorer() {
$url = $this->urlGenerator
->generate('graphql.request');
return [
'#type' => 'page',
'#theme' => 'page__graphql_explorer',
'#attached' => [
'library' => [
'graphql/explorer',
],
'drupalSettings' => [
'graphQLRequestUrl' => $url,
],
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExplorerController:: |
protected | property | The URL generator service. | |
ExplorerController:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
ExplorerController:: |
public | function | Controller for the GraphiQL query builder IDE. | |
ExplorerController:: |
public | function | Constructs a ExplorerController object. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |