class LanguageNegotiationGraphQL in GraphQL 8.3
Class for identifying language from a selected language.
Plugin annotation
@LanguageNegotiation(
id = Drupal\graphql\Plugin\LanguageNegotiation\LanguageNegotiationGraphQL::METHOD_ID,
weight = -999,
name = @Translation("GraphQL context"),
description = @Translation("The current GraphQL language context. Only available while executing a query.")
)
Hierarchy
- class \Drupal\language\LanguageNegotiationMethodBase implements LanguageNegotiationMethodInterface
- class \Drupal\graphql\Plugin\LanguageNegotiation\LanguageNegotiationGraphQL implements ContainerFactoryPluginInterface
Expanded class hierarchy of LanguageNegotiationGraphQL
File
- src/
Plugin/ LanguageNegotiation/ LanguageNegotiationGraphQL.php, line 21
Namespace
Drupal\graphql\Plugin\LanguageNegotiationView source
class LanguageNegotiationGraphQL extends LanguageNegotiationMethodBase implements ContainerFactoryPluginInterface {
/**
* The graphql language context.
*
* @var \Drupal\graphql\GraphQLLanguageContext
*/
protected $languageContext;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($container
->get('graphql.language_context'));
}
/**
* LanguageNegotiationGraphQL constructor.
*
* @param \Drupal\graphql\GraphQLLanguageContext $languageContext
* Instance of the GraphQL language context.
*/
public function __construct(GraphQLLanguageContext $languageContext) {
$this->languageContext = $languageContext;
}
/**
* The language negotiation method id.
*/
const METHOD_ID = 'language-graphql';
/**
* {@inheritdoc}
*/
public function getLangcode(Request $request = NULL) {
return $this->languageContext
->getCurrentLanguage();
}
}