1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Digia\GraphQL\Language\Node; |
4
|
|
|
|
5
|
|
|
use Digia\GraphQL\Language\Location; |
6
|
|
|
|
7
|
|
|
class SchemaDefinitionNode extends AbstractNode implements TypeSystemDefinitionNodeInterface, DirectivesAwareInterface |
8
|
|
|
{ |
9
|
|
|
use DirectivesTrait; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @var OperationTypeDefinitionNode[] |
13
|
|
|
*/ |
14
|
|
|
protected $operationTypes; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* SchemaDefinitionNode constructor. |
18
|
|
|
* |
19
|
|
|
* @param DirectiveNode[] $directives |
20
|
|
|
* @param OperationTypeDefinitionNode[] $operationTypes |
21
|
|
|
* @param Location|null $location |
22
|
|
|
*/ |
23
|
|
|
public function __construct(array $directives, array $operationTypes, ?Location $location) |
24
|
|
|
{ |
25
|
|
|
parent::__construct(NodeKindEnum::SCHEMA_DEFINITION, $location); |
26
|
|
|
|
27
|
|
|
$this->directives = $directives; |
28
|
|
|
$this->operationTypes = $operationTypes; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @return OperationTypeDefinitionNode[] |
33
|
|
|
*/ |
34
|
|
|
public function getOperationTypes(): array |
35
|
|
|
{ |
36
|
|
|
return $this->operationTypes; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @return array |
41
|
|
|
*/ |
42
|
|
|
public function getOperationTypesAST(): array |
43
|
|
|
{ |
44
|
|
|
return \array_map(function (OperationTypeDefinitionNode $node) { |
45
|
|
|
return $node->toAST(); |
46
|
|
|
}, $this->operationTypes); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param OperationTypeDefinitionNode[] $operationTypes |
51
|
|
|
* @return $this |
52
|
|
|
*/ |
53
|
|
|
public function setOperationTypes(array $operationTypes) |
54
|
|
|
{ |
55
|
|
|
$this->operationTypes = $operationTypes; |
56
|
|
|
return $this; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @inheritdoc |
61
|
|
|
*/ |
62
|
|
|
public function toAST(): array |
63
|
|
|
{ |
64
|
|
|
return [ |
65
|
|
|
'kind' => $this->kind, |
66
|
|
|
'directives' => $this->getDirectivesAST(), |
67
|
|
|
'operationTypes' => $this->getOperationTypesAST(), |
68
|
|
|
'loc' => $this->getLocationAST(), |
69
|
|
|
]; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return NameNode|null |
74
|
|
|
*/ |
75
|
|
|
public function getName(): ?NameNode |
76
|
|
|
{ |
77
|
|
|
// TODO: Implement getName() method. |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return null|string |
82
|
|
|
*/ |
83
|
|
|
public function getNameValue(): ?string |
84
|
|
|
{ |
85
|
|
|
// TODO: Implement getNameValue() method. |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|