Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TypeMetaWrapperReader.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
14 {
15  const ARGUMENT_PARAMETER = 'Argument';
16 
17  const OUTPUT_FIELD_PARAMETER = 'OutputField';
18 
19  const INPUT_FIELD_PARAMETER = 'InputField';
20 
28  public function read(\GraphQL\Type\Definition\Type $meta, string $parameterType) : array
29  {
30  $result = [];
31  if ($meta instanceof \GraphQL\Type\Definition\NonNull) {
32  $result['required'] = true;
33  $meta = $meta->getWrappedType();
34  } else {
35  $result['required'] = false;
36  }
37  if ($meta instanceof \GraphQL\Type\Definition\ListOfType) {
38  $itemTypeMeta = $meta->ofType;
39  if ($itemTypeMeta instanceof \GraphQL\Type\Definition\NonNull) {
40  $result['itemsRequired'] = true;
41  $itemTypeMeta = $itemTypeMeta->getWrappedType();
42  } else {
43  $result['itemsRequired'] = false;
44  }
45  $itemTypeName = $itemTypeMeta->name;
46  $result['itemType'] = $itemTypeName;
47  if ($itemTypeMeta instanceof \GraphQL\Type\Definition\ScalarType) {
48  $result['type'] = 'ScalarArray' . $parameterType;
49  } else {
50  $result['type'] = 'ObjectArray' . $parameterType;
51  }
52  } else {
53  $result['type'] = $meta->name;
54  }
55 
56  return $result;
57  }
58 }