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