class OperationLanguageNegotiation in GraphQL 8.4
Class for identifying language based on a graphql query.
Plugin annotation
@LanguageNegotiation(
id = Drupal\graphql\Plugin\LanguageNegotiation\OperationLanguageNegotiation::METHOD_ID,
weight = -999,
name = @Translation("GraphQL operation context"),
description = @Translation("Determines the language in the context of an operation.")
)
Hierarchy
- class \Drupal\language\LanguageNegotiationMethodBase implements LanguageNegotiationMethodInterface
- class \Drupal\graphql\Plugin\LanguageNegotiation\OperationLanguageNegotiation
Expanded class hierarchy of OperationLanguageNegotiation
1 file declares its use of OperationLanguageNegotiation
- OperationSubscriber.php in src/
EventSubscriber/ OperationSubscriber.php
File
- src/
Plugin/ LanguageNegotiation/ OperationLanguageNegotiation.php, line 19
Namespace
Drupal\graphql\Plugin\LanguageNegotiationView source
class OperationLanguageNegotiation extends LanguageNegotiationMethodBase {
/**
* The language negotiation method id.
*/
const METHOD_ID = 'language-graphql-operation';
/**
* The request stack.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $requestStack;
/**
* The current execution context.
*
* @var \Drupal\graphql\GraphQL\Execution\ResolveContext
*/
protected static $context;
/**
* {@inheritdoc}
*/
public function getLangcode(Request $request = NULL) {
if (!empty(static::$context)) {
return static::$context
->getContextLanguage();
}
return FALSE;
}
/**
* Set the current resolve context statically which contains the language.
*
* @param \Drupal\graphql\GraphQL\Execution\ResolveContext $context
*/
public static function setContext(ResolveContext $context = NULL) : void {
static::$context = $context;
}
}