You are here

public static function TypedDataTypeResolver::getPropertyPrimitiveValue in GraphQL 8.2

Same name and namespace in other branches
  1. 8 src/TypeResolver/TypedDataTypeResolver.php \Drupal\graphql\TypeResolver\TypedDataTypeResolver::getPropertyPrimitiveValue()

Property value resolver callback for primitive properties.

Parameters

\Drupal\Core\TypedData\ComplexDataInterface $data: The parent complex data structure to extract the property from.

Return value

mixed The resolved value.

File

src/TypeResolver/TypedDataTypeResolver.php, line 384

Class

TypedDataTypeResolver
Generically resolves the schema for typed data types.

Namespace

Drupal\graphql\TypeResolver

Code

public static function getPropertyPrimitiveValue(ComplexDataInterface $data = NULL, $a, $b, $c, $d, $e, $f, $config) {
  if (!isset($data)) {
    return NULL;
  }
  $value = $data
    ->get($config['property']);
  if ($value instanceof AccessibleInterface && !$value
    ->access('view')) {
    return NULL;
  }
  return $value
    ->getValue();
}