You are here

protected function EntityQueryEntities::negotiateLanguage in GraphQL 8.3

Negotiate the language for the resolved entities.

Parameters

mixed $metadata: The query context.

array $args: The field arguments array.

\Drupal\graphql\GraphQL\Execution\ResolveContext $context: The resolve context.

\GraphQL\Type\Definition\ResolveInfo $info: The resolve info object.

Return value

string|null The negotiated language id.

1 call to EntityQueryEntities::negotiateLanguage()
EntityQueryEntities::resolveEntities in modules/graphql_core/src/Plugin/GraphQL/Fields/EntityQuery/EntityQueryEntities.php
Resolves entity objects and checks view permissions.

File

modules/graphql_core/src/Plugin/GraphQL/Fields/EntityQuery/EntityQueryEntities.php, line 236

Class

EntityQueryEntities
Retrieve the entity result set of an entity query.

Namespace

Drupal\graphql_core\Plugin\GraphQL\Fields\EntityQuery

Code

protected function negotiateLanguage($metadata, $args, ResolveContext $context, ResolveInfo $info) {
  if (!empty($args['language'])) {
    return $args['language'];
  }
  if (isset($metadata['parent']) && ($parent = $metadata['parent']) && $parent instanceof EntityInterface) {
    return $parent
      ->language()
      ->getId();
  }
  return NULL;
}