1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Overblog\GraphQLBundle\Event; |
6
|
|
|
|
7
|
|
|
use Overblog\GraphQLBundle\Definition\Type\ExtensibleSchema; |
8
|
|
|
use Symfony\Contracts\EventDispatcher\Event; |
9
|
|
|
|
10
|
|
|
// TODO(mcg-web): remove hack after migrjating Symfony >= 4.3 |
11
|
1 |
|
if (EventDispatcherVersionHelper::isForLegacy()) { |
12
|
|
|
final class ExecutorArgumentsEvent extends \Symfony\Component\EventDispatcher\Event |
|
|
|
|
13
|
|
|
{ |
14
|
|
|
/** @var ExtensibleSchema */ |
15
|
|
|
private $schema; |
16
|
|
|
|
17
|
|
|
/** @var string */ |
18
|
|
|
private $requestString; |
19
|
|
|
|
20
|
|
|
/** @var mixed */ |
21
|
|
|
private $rootValue; |
22
|
|
|
|
23
|
|
|
/** @var \ArrayObject */ |
24
|
|
|
private $contextValue; |
25
|
|
|
|
26
|
|
|
/** @var array|null */ |
27
|
|
|
private $variableValue; |
28
|
|
|
|
29
|
|
|
/** @var string|null */ |
30
|
|
|
private $operationName; |
31
|
|
|
|
32
|
|
|
public static function create( |
33
|
|
|
ExtensibleSchema $schema, |
34
|
|
|
$requestString, |
35
|
|
|
\ArrayObject $contextValue, |
36
|
|
|
$rootValue = null, |
37
|
|
|
array $variableValue = null, |
38
|
|
|
$operationName = null |
39
|
|
|
) { |
40
|
|
|
$instance = new static(); |
41
|
|
|
$instance->setSchema($schema); |
42
|
|
|
$instance->setRequestString($requestString); |
43
|
|
|
$instance->setContextValue($contextValue); |
44
|
|
|
$instance->setRootValue($rootValue); |
45
|
|
|
$instance->setVariableValue($variableValue); |
46
|
|
|
$instance->setOperationName($operationName); |
47
|
|
|
|
48
|
|
|
return $instance; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param string|null $operationName |
53
|
|
|
*/ |
54
|
|
|
public function setOperationName($operationName = null): void |
55
|
|
|
{ |
56
|
|
|
$this->operationName = $operationName; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function setContextValue(\ArrayObject $contextValue = null): void |
60
|
|
|
{ |
61
|
|
|
$this->contextValue = $contextValue; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param mixed $rootValue |
66
|
|
|
*/ |
67
|
|
|
public function setRootValue($rootValue = null): void |
68
|
|
|
{ |
69
|
|
|
$this->rootValue = $rootValue; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param string $requestString |
74
|
|
|
*/ |
75
|
|
|
public function setRequestString($requestString): void |
76
|
|
|
{ |
77
|
|
|
$this->requestString = $requestString; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function setVariableValue(array $variableValue = null): void |
81
|
|
|
{ |
82
|
|
|
$this->variableValue = $variableValue; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function setSchema(ExtensibleSchema $schema): void |
86
|
|
|
{ |
87
|
|
|
$this->schema = $schema; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return ExtensibleSchema |
92
|
|
|
*/ |
93
|
|
|
public function getSchema(): ExtensibleSchema |
94
|
|
|
{ |
95
|
|
|
return $this->schema; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @return string |
100
|
|
|
*/ |
101
|
|
|
public function getRequestString(): string |
102
|
|
|
{ |
103
|
|
|
return $this->requestString; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return array|null |
108
|
|
|
*/ |
109
|
|
|
public function getRootValue() |
110
|
|
|
{ |
111
|
|
|
return $this->rootValue; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @return \ArrayObject |
116
|
|
|
*/ |
117
|
|
|
public function getContextValue(): \ArrayObject |
118
|
|
|
{ |
119
|
|
|
return $this->contextValue; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @return array|null |
124
|
|
|
*/ |
125
|
|
|
public function getVariableValue() |
126
|
|
|
{ |
127
|
|
|
return $this->variableValue; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @return string|null |
132
|
|
|
*/ |
133
|
|
|
public function getOperationName() |
134
|
|
|
{ |
135
|
|
|
return $this->operationName; |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
} else { |
139
|
|
|
final class ExecutorArgumentsEvent extends Event |
140
|
|
|
{ |
141
|
|
|
/** @var ExtensibleSchema */ |
142
|
|
|
private $schema; |
143
|
|
|
|
144
|
|
|
/** @var string */ |
145
|
|
|
private $requestString; |
146
|
|
|
|
147
|
|
|
/** @var mixed */ |
148
|
|
|
private $rootValue; |
149
|
|
|
|
150
|
|
|
/** @var \ArrayObject */ |
151
|
|
|
private $contextValue; |
152
|
|
|
|
153
|
|
|
/** @var array|null */ |
154
|
|
|
private $variableValue; |
155
|
|
|
|
156
|
|
|
/** @var string|null */ |
157
|
|
|
private $operationName; |
158
|
|
|
|
159
|
85 |
|
public static function create( |
160
|
|
|
ExtensibleSchema $schema, |
161
|
|
|
$requestString, |
162
|
|
|
\ArrayObject $contextValue, |
163
|
|
|
$rootValue = null, |
164
|
|
|
array $variableValue = null, |
165
|
|
|
$operationName = null |
166
|
|
|
) { |
167
|
85 |
|
$instance = new static(); |
168
|
85 |
|
$instance->setSchema($schema); |
169
|
85 |
|
$instance->setRequestString($requestString); |
170
|
85 |
|
$instance->setContextValue($contextValue); |
171
|
85 |
|
$instance->setRootValue($rootValue); |
172
|
85 |
|
$instance->setVariableValue($variableValue); |
173
|
85 |
|
$instance->setOperationName($operationName); |
174
|
|
|
|
175
|
85 |
|
return $instance; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @param string|null $operationName |
180
|
|
|
*/ |
181
|
85 |
|
public function setOperationName($operationName = null): void |
182
|
|
|
{ |
183
|
85 |
|
$this->operationName = $operationName; |
184
|
85 |
|
} |
185
|
|
|
|
186
|
85 |
|
public function setContextValue(\ArrayObject $contextValue = null): void |
187
|
|
|
{ |
188
|
85 |
|
$this->contextValue = $contextValue; |
189
|
85 |
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @param mixed $rootValue |
193
|
|
|
*/ |
194
|
85 |
|
public function setRootValue($rootValue = null): void |
195
|
|
|
{ |
196
|
85 |
|
$this->rootValue = $rootValue; |
197
|
85 |
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @param string $requestString |
201
|
|
|
*/ |
202
|
85 |
|
public function setRequestString($requestString): void |
203
|
|
|
{ |
204
|
85 |
|
$this->requestString = $requestString; |
205
|
85 |
|
} |
206
|
|
|
|
207
|
85 |
|
public function setVariableValue(array $variableValue = null): void |
208
|
|
|
{ |
209
|
85 |
|
$this->variableValue = $variableValue; |
210
|
85 |
|
} |
211
|
|
|
|
212
|
85 |
|
public function setSchema(ExtensibleSchema $schema): void |
213
|
|
|
{ |
214
|
85 |
|
$this->schema = $schema; |
215
|
85 |
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* @return ExtensibleSchema |
219
|
|
|
*/ |
220
|
85 |
|
public function getSchema(): ExtensibleSchema |
221
|
|
|
{ |
222
|
85 |
|
return $this->schema; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* @return string |
227
|
|
|
*/ |
228
|
85 |
|
public function getRequestString(): string |
229
|
|
|
{ |
230
|
85 |
|
return $this->requestString; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* @return array|null |
235
|
|
|
*/ |
236
|
85 |
|
public function getRootValue() |
237
|
|
|
{ |
238
|
85 |
|
return $this->rootValue; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* @return \ArrayObject |
243
|
|
|
*/ |
244
|
85 |
|
public function getContextValue(): \ArrayObject |
245
|
|
|
{ |
246
|
85 |
|
return $this->contextValue; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* @return array|null |
251
|
|
|
*/ |
252
|
85 |
|
public function getVariableValue() |
253
|
|
|
{ |
254
|
85 |
|
return $this->variableValue; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* @return string|null |
259
|
|
|
*/ |
260
|
85 |
|
public function getOperationName() |
261
|
|
|
{ |
262
|
85 |
|
return $this->operationName; |
263
|
|
|
} |
264
|
|
|
} |
265
|
|
|
} |
266
|
|
|
|