You are here

public static function ContentEntityTypeResolver::getFieldValueSimplified in GraphQL 8

Same name and namespace in other branches
  1. 8.2 src/TypeResolver/ContentEntityTypeResolver.php \Drupal\graphql\TypeResolver\ContentEntityTypeResolver::getFieldValueSimplified()

Property value resolver callback for primitive properties.

Parameters

\Drupal\Core\Entity\Plugin\DataType\EntityAdapter $data: The parent complex data structure to extract the property from.

Return value

mixed The resolved value.

File

src/TypeResolver/ContentEntityTypeResolver.php, line 319

Class

ContentEntityTypeResolver
Resolves the schema for content entities.

Namespace

Drupal\graphql\TypeResolver

Code

public static function getFieldValueSimplified(EntityAdapter $data, $a, $b, $c, $d, $e, $f, $config) {
  $skipList = $config['skipList'];
  $skipSubSelection = $config['skipSubSelection'];
  $property = $config['property'];
  $subProperty = $config['subProperty'];
  $finalResolver = $config['finalResolver'];
  $data = $data
    ->get($property);
  if ($data instanceof AccessibleInterface && !$data
    ->access('view')) {
    return NULL;
  }
  $data = $skipList ? [
    $data
      ->get(0),
  ] : iterator_to_array($data);
  $args = [
    $a,
    $b,
    $c,
    $d,
    $e,
    $f,
    [
      'property' => $subProperty,
    ],
  ];
  $data = $skipSubSelection ? array_map(function ($item) use ($finalResolver, $args) {
    return call_user_func_array($finalResolver, array_merge([
      $item,
    ], $args));
  }, $data) : $data;
  return $skipList ? reset($data) : $data;
}