You are here

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

Expanded class hierarchy of LanguageNegotiationGraphQL

File

src/Plugin/LanguageNegotiation/LanguageNegotiationGraphQL.php, line 21

Namespace

Drupal\graphql\Plugin\LanguageNegotiation
View 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();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LanguageNegotiationGraphQL::$languageContext protected property The graphql language context.
LanguageNegotiationGraphQL::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
LanguageNegotiationGraphQL::getLangcode public function Performs language negotiation. Overrides LanguageNegotiationMethodInterface::getLangcode
LanguageNegotiationGraphQL::METHOD_ID constant The language negotiation method id.
LanguageNegotiationGraphQL::__construct public function LanguageNegotiationGraphQL constructor.
LanguageNegotiationMethodBase::$config protected property The configuration factory.
LanguageNegotiationMethodBase::$currentUser protected property The current active user.
LanguageNegotiationMethodBase::$languageManager protected property The language manager.
LanguageNegotiationMethodBase::persist public function Notifies the plugin that the language code it returned has been accepted. Overrides LanguageNegotiationMethodInterface::persist 1
LanguageNegotiationMethodBase::setConfig public function Injects the configuration factory. Overrides LanguageNegotiationMethodInterface::setConfig
LanguageNegotiationMethodBase::setCurrentUser public function Injects the current user. Overrides LanguageNegotiationMethodInterface::setCurrentUser
LanguageNegotiationMethodBase::setLanguageManager public function Injects the language manager. Overrides LanguageNegotiationMethodInterface::setLanguageManager