1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the API Platform project. |
5
|
|
|
* |
6
|
|
|
* (c) Kévin Dunglas <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace ApiPlatform\Core\Annotation; |
15
|
|
|
|
16
|
|
|
use ApiPlatform\Core\Exception\InvalidArgumentException; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* ApiResource annotation. |
20
|
|
|
* |
21
|
|
|
* @author Kévin Dunglas <[email protected]> |
22
|
|
|
* |
23
|
|
|
* @Annotation |
24
|
|
|
* @Target({"CLASS"}) |
25
|
|
|
* @Attributes( |
26
|
|
|
* @Attribute("accessControl", type="string"), |
27
|
|
|
* @Attribute("accessControlMessage", type="string"), |
28
|
|
|
* @Attribute("security", type="string"), |
29
|
|
|
* @Attribute("securityMessage", type="string"), |
30
|
|
|
* @Attribute("securityPostDenormalize", type="string"), |
31
|
|
|
* @Attribute("securityPostDenormalizeMessage", type="string"), |
32
|
|
|
* @Attribute("attributes", type="array"), |
33
|
|
|
* @Attribute("cacheHeaders", type="array"), |
34
|
|
|
* @Attribute("collectionOperations", type="array"), |
35
|
|
|
* @Attribute("denormalizationContext", type="array"), |
36
|
|
|
* @Attribute("deprecationReason", type="string"), |
37
|
|
|
* @Attribute("description", type="string"), |
38
|
|
|
* @Attribute("elasticsearch", type="bool"), |
39
|
|
|
* @Attribute("fetchPartial", type="bool"), |
40
|
|
|
* @Attribute("forceEager", type="bool"), |
41
|
|
|
* @Attribute("formats", type="array"), |
42
|
|
|
* @Attribute("filters", type="string[]"), |
43
|
|
|
* @Attribute("graphql", type="array"), |
44
|
|
|
* @Attribute("hydraContext", type="array"), |
45
|
|
|
* @Attribute("input", type="mixed"), |
46
|
|
|
* @Attribute("iri", type="string"), |
47
|
|
|
* @Attribute("itemOperations", type="array"), |
48
|
|
|
* @Attribute("mercure", type="mixed"), |
49
|
|
|
* @Attribute("messenger", type="mixed"), |
50
|
|
|
* @Attribute("normalizationContext", type="array"), |
51
|
|
|
* @Attribute("openapiContext", type="array"), |
52
|
|
|
* @Attribute("order", type="array"), |
53
|
|
|
* @Attribute("output", type="mixed"), |
54
|
|
|
* @Attribute("paginationClientEnabled", type="bool"), |
55
|
|
|
* @Attribute("paginationClientItemsPerPage", type="bool"), |
56
|
|
|
* @Attribute("paginationClientPartial", type="bool"), |
57
|
|
|
* @Attribute("paginationEnabled", type="bool"), |
58
|
|
|
* @Attribute("paginationFetchJoinCollection", type="bool"), |
59
|
|
|
* @Attribute("paginationItemsPerPage", type="int"), |
60
|
|
|
* @Attribute("maximumItemsPerPage", type="int"), |
61
|
|
|
* @Attribute("paginationMaximumItemsPerPage", type="int"), |
62
|
|
|
* @Attribute("paginationPartial", type="bool"), |
63
|
|
|
* @Attribute("paginationViaCursor", type="array"), |
64
|
|
|
* @Attribute("routePrefix", type="string"), |
65
|
|
|
* @Attribute("shortName", type="string"), |
66
|
|
|
* @Attribute("subresourceOperations", type="array"), |
67
|
|
|
* @Attribute("sunset", type="string"), |
68
|
|
|
* @Attribute("swaggerContext", type="array"), |
69
|
|
|
* @Attribute("validationGroups", type="mixed") |
70
|
|
|
* ) |
71
|
|
|
*/ |
72
|
|
|
final class ApiResource |
73
|
|
|
{ |
74
|
|
|
use AttributesHydratorTrait; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @var string |
78
|
|
|
*/ |
79
|
|
|
public $shortName; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @var string |
83
|
|
|
*/ |
84
|
|
|
public $description; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @var string |
88
|
|
|
*/ |
89
|
|
|
public $iri; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @var array |
93
|
|
|
*/ |
94
|
|
|
public $itemOperations; |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @var array |
98
|
|
|
*/ |
99
|
|
|
public $collectionOperations; |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @var array |
103
|
|
|
*/ |
104
|
|
|
public $subresourceOperations; |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @var array |
108
|
|
|
*/ |
109
|
|
|
public $graphql; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
113
|
|
|
* |
114
|
|
|
* @var string |
115
|
|
|
*/ |
116
|
|
|
private $security; |
|
|
|
|
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
120
|
|
|
* |
121
|
|
|
* @var string |
122
|
|
|
*/ |
123
|
|
|
private $securityMessage; |
|
|
|
|
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
127
|
|
|
* |
128
|
|
|
* @var string |
129
|
|
|
*/ |
130
|
|
|
private $securityPostDenormalize; |
|
|
|
|
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
134
|
|
|
* |
135
|
|
|
* @var string |
136
|
|
|
*/ |
137
|
|
|
private $securityPostDenormalizeMessage; |
|
|
|
|
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
141
|
|
|
* |
142
|
|
|
* @var array |
143
|
|
|
*/ |
144
|
|
|
private $cacheHeaders; |
|
|
|
|
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
148
|
|
|
* |
149
|
|
|
* @var array |
150
|
|
|
*/ |
151
|
|
|
private $denormalizationContext; |
|
|
|
|
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
155
|
|
|
* |
156
|
|
|
* @var string |
157
|
|
|
*/ |
158
|
|
|
private $deprecationReason; |
|
|
|
|
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
162
|
|
|
* |
163
|
|
|
* @var bool |
164
|
|
|
*/ |
165
|
|
|
private $elasticsearch; |
|
|
|
|
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
169
|
|
|
* |
170
|
|
|
* @var bool |
171
|
|
|
*/ |
172
|
|
|
private $fetchPartial; |
|
|
|
|
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
176
|
|
|
* |
177
|
|
|
* @var bool |
178
|
|
|
*/ |
179
|
|
|
private $forceEager; |
|
|
|
|
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
183
|
|
|
* |
184
|
|
|
* @var array |
185
|
|
|
*/ |
186
|
|
|
private $formats; |
|
|
|
|
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
190
|
|
|
* |
191
|
|
|
* @var string[] |
192
|
|
|
*/ |
193
|
|
|
private $filters; |
|
|
|
|
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
197
|
|
|
* |
198
|
|
|
* @var string[] |
199
|
|
|
*/ |
200
|
|
|
private $hydraContext; |
|
|
|
|
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
204
|
|
|
* |
205
|
|
|
* @var mixed |
206
|
|
|
*/ |
207
|
|
|
private $mercure; |
|
|
|
|
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
211
|
|
|
* |
212
|
|
|
* @var bool|string |
213
|
|
|
*/ |
214
|
|
|
private $messenger; |
|
|
|
|
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
218
|
|
|
* |
219
|
|
|
* @var array |
220
|
|
|
*/ |
221
|
|
|
private $normalizationContext; |
|
|
|
|
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
225
|
|
|
* |
226
|
|
|
* @var array |
227
|
|
|
*/ |
228
|
|
|
private $order; |
|
|
|
|
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
232
|
|
|
* |
233
|
|
|
* @var bool |
234
|
|
|
*/ |
235
|
|
|
private $paginationClientEnabled; |
|
|
|
|
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
239
|
|
|
* |
240
|
|
|
* @var bool |
241
|
|
|
*/ |
242
|
|
|
private $paginationClientItemsPerPage; |
|
|
|
|
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
246
|
|
|
* |
247
|
|
|
* @var bool |
248
|
|
|
*/ |
249
|
|
|
private $paginationClientPartial; |
|
|
|
|
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
253
|
|
|
* |
254
|
|
|
* @var bool |
255
|
|
|
*/ |
256
|
|
|
private $paginationEnabled; |
|
|
|
|
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
260
|
|
|
* |
261
|
|
|
* @var bool |
262
|
|
|
*/ |
263
|
|
|
private $paginationFetchJoinCollection; |
|
|
|
|
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
267
|
|
|
* |
268
|
|
|
* @var int |
269
|
|
|
*/ |
270
|
|
|
private $paginationItemsPerPage; |
|
|
|
|
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
274
|
|
|
* |
275
|
|
|
* @var int |
276
|
|
|
* |
277
|
|
|
* @deprecated - Use $paginationMaximumItemsPerPage instead |
278
|
|
|
*/ |
279
|
|
|
private $maximumItemsPerPage; |
|
|
|
|
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
283
|
|
|
* |
284
|
|
|
* @var int |
285
|
|
|
*/ |
286
|
|
|
private $paginationMaximumItemsPerPage; |
|
|
|
|
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
290
|
|
|
* |
291
|
|
|
* @var int |
292
|
|
|
*/ |
293
|
|
|
private $paginationPartial; |
|
|
|
|
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
297
|
|
|
* |
298
|
|
|
* @var string |
299
|
|
|
*/ |
300
|
|
|
private $routePrefix; |
|
|
|
|
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
304
|
|
|
* |
305
|
|
|
* @var array |
306
|
|
|
*/ |
307
|
|
|
private $swaggerContext; |
|
|
|
|
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
311
|
|
|
* |
312
|
|
|
* @var mixed |
313
|
|
|
*/ |
314
|
|
|
private $validationGroups; |
|
|
|
|
315
|
|
|
|
316
|
|
|
/** |
317
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
318
|
|
|
* |
319
|
|
|
* @var string |
320
|
|
|
*/ |
321
|
|
|
private $sunset; |
|
|
|
|
322
|
|
|
|
323
|
|
|
/** |
324
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
325
|
|
|
* |
326
|
|
|
* @var string|false |
327
|
|
|
*/ |
328
|
|
|
private $input; |
|
|
|
|
329
|
|
|
|
330
|
|
|
/** |
331
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
332
|
|
|
* |
333
|
|
|
* @var string|false |
334
|
|
|
*/ |
335
|
|
|
private $output; |
|
|
|
|
336
|
|
|
|
337
|
|
|
/** |
338
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
339
|
|
|
* |
340
|
|
|
* @var array |
341
|
|
|
*/ |
342
|
|
|
private $openapiContext; |
|
|
|
|
343
|
|
|
|
344
|
|
|
/** |
345
|
|
|
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
346
|
|
|
* |
347
|
|
|
* @var array |
348
|
|
|
*/ |
349
|
|
|
private $paginationViaCursor; |
|
|
|
|
350
|
|
|
|
351
|
|
|
/** |
352
|
|
|
* @throws InvalidArgumentException |
353
|
|
|
*/ |
354
|
|
|
public function __construct(array $values = []) |
355
|
|
|
{ |
356
|
|
|
$this->hydrateAttributes($values); |
357
|
|
|
} |
358
|
|
|
} |
359
|
|
|
|