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("attributes", type="array"), |
||
29 | * @Attribute("cacheHeaders", type="array"), |
||
30 | * @Attribute("collectionOperations", type="array"), |
||
31 | * @Attribute("denormalizationContext", type="array"), |
||
32 | * @Attribute("deprecationReason", type="string"), |
||
33 | * @Attribute("description", type="string"), |
||
34 | * @Attribute("elasticsearch", type="bool"), |
||
35 | * @Attribute("fetchPartial", type="bool"), |
||
36 | * @Attribute("forceEager", type="bool"), |
||
37 | * @Attribute("formats", type="array"), |
||
38 | * @Attribute("filters", type="string[]"), |
||
39 | * @Attribute("graphql", type="array"), |
||
40 | * @Attribute("hydraContext", type="array"), |
||
41 | * @Attribute("input", type="mixed"), |
||
42 | * @Attribute("iri", type="string"), |
||
43 | * @Attribute("itemOperations", type="array"), |
||
44 | * @Attribute("mercure", type="mixed"), |
||
45 | * @Attribute("messenger", type="mixed"), |
||
46 | * @Attribute("normalizationContext", type="array"), |
||
47 | * @Attribute("openapiContext", type="array"), |
||
48 | * @Attribute("order", type="array"), |
||
49 | * @Attribute("output", type="mixed"), |
||
50 | * @Attribute("paginationClientEnabled", type="bool"), |
||
51 | * @Attribute("paginationClientItemsPerPage", type="bool"), |
||
52 | * @Attribute("paginationClientPartial", type="bool"), |
||
53 | * @Attribute("paginationEnabled", type="bool"), |
||
54 | * @Attribute("paginationFetchJoinCollection", type="bool"), |
||
55 | * @Attribute("paginationItemsPerPage", type="int"), |
||
56 | * @Attribute("maximumItemsPerPage", type="int"), |
||
57 | * @Attribute("paginationMaximumItemsPerPage", type="int"), |
||
58 | * @Attribute("paginationPartial", type="bool"), |
||
59 | * @Attribute("paginationViaCursor", type="array"), |
||
60 | * @Attribute("routePrefix", type="string"), |
||
61 | * @Attribute("security", type="string"), |
||
62 | * @Attribute("securityMessage", type="string"), |
||
63 | * @Attribute("securityPostDenormalize", type="string"), |
||
64 | * @Attribute("securityPostDenormalizeMessage", 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 | * @internal |
||
78 | * |
||
79 | * @see \ApiPlatform\Core\Bridge\Symfony\Bundle\DependencyInjection\Configuration::addDefaultsSection |
||
80 | */ |
||
81 | public const CONFIGURABLE_DEFAULTS = [ |
||
82 | 'accessControl', |
||
83 | 'accessControlMessage', |
||
84 | 'security', |
||
85 | 'securityMessage', |
||
86 | 'securityPostDenormalize', |
||
87 | 'securityPostDenormalizeMessage', |
||
88 | 'cacheHeaders', |
||
89 | 'collectionOperations', |
||
90 | 'denormalizationContext', |
||
91 | 'deprecationReason', |
||
92 | 'description', |
||
93 | 'elasticsearch', |
||
94 | 'fetchPartial', |
||
95 | 'forceEager', |
||
96 | 'formats', |
||
97 | 'filters', |
||
98 | 'graphql', |
||
99 | 'hydraContext', |
||
100 | 'input', |
||
101 | 'iri', |
||
102 | 'itemOperations', |
||
103 | 'mercure', |
||
104 | 'messenger', |
||
105 | 'normalizationContext', |
||
106 | 'openapiContext', |
||
107 | 'order', |
||
108 | 'output', |
||
109 | 'paginationClientEnabled', |
||
110 | 'paginationClientItemsPerPage', |
||
111 | 'paginationClientPartial', |
||
112 | 'paginationEnabled', |
||
113 | 'paginationFetchJoinCollection', |
||
114 | 'paginationItemsPerPage', |
||
115 | 'maximumItemsPerPage', |
||
116 | 'paginationMaximumItemsPerPage', |
||
117 | 'paginationPartial', |
||
118 | 'paginationViaCursor', |
||
119 | 'routePrefix', |
||
120 | 'sunset', |
||
121 | 'swaggerContext', |
||
122 | 'validationGroups', |
||
123 | ]; |
||
124 | |||
125 | /** |
||
126 | * @see https://api-platform.com/docs/core/operations |
||
127 | * |
||
128 | * @var array |
||
129 | */ |
||
130 | public $collectionOperations; |
||
131 | |||
132 | /** |
||
133 | * @var string |
||
134 | */ |
||
135 | public $description; |
||
136 | |||
137 | /** |
||
138 | * @see https://api-platform.com/docs/core/graphql |
||
139 | * |
||
140 | * @var array |
||
141 | */ |
||
142 | public $graphql; |
||
143 | |||
144 | /** |
||
145 | * @var string |
||
146 | */ |
||
147 | public $iri; |
||
148 | |||
149 | /** |
||
150 | * @see https://api-platform.com/docs/core/operations |
||
151 | * |
||
152 | * @var array |
||
153 | */ |
||
154 | public $itemOperations; |
||
155 | |||
156 | /** |
||
157 | * @var string |
||
158 | */ |
||
159 | public $shortName; |
||
160 | |||
161 | /** |
||
162 | * @see https://api-platform.com/docs/core/subresources |
||
163 | * |
||
164 | * @var array |
||
165 | */ |
||
166 | public $subresourceOperations; |
||
167 | |||
168 | /** |
||
169 | * @see https://api-platform.com/docs/core/performance/#setting-custom-http-cache-headers |
||
170 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
171 | * |
||
172 | * @var array |
||
173 | */ |
||
174 | private $cacheHeaders; |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
175 | |||
176 | /** |
||
177 | * @see https://api-platform.com/docs/core/serialization/#using-serialization-groups |
||
178 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
179 | * |
||
180 | * @var array |
||
181 | */ |
||
182 | private $denormalizationContext; |
||
183 | |||
184 | /** |
||
185 | * @see https://api-platform.com/docs/core/deprecations/#deprecating-resource-classes-operations-and-properties |
||
186 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
187 | * |
||
188 | * @var string |
||
189 | */ |
||
190 | private $deprecationReason; |
||
191 | |||
192 | /** |
||
193 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
194 | * |
||
195 | * @var bool |
||
196 | */ |
||
197 | private $elasticsearch; |
||
198 | |||
199 | /** |
||
200 | * @see https://api-platform.com/docs/core/performance/#fetch-partial |
||
201 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
202 | * |
||
203 | * @var bool |
||
204 | */ |
||
205 | private $fetchPartial; |
||
206 | |||
207 | /** |
||
208 | * @see https://api-platform.com/docs/core/performance/#force-eager |
||
209 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
210 | * |
||
211 | * @var bool |
||
212 | */ |
||
213 | private $forceEager; |
||
214 | |||
215 | /** |
||
216 | * @see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation |
||
217 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
218 | * |
||
219 | * @var array |
||
220 | */ |
||
221 | private $formats; |
||
222 | |||
223 | /** |
||
224 | * @see https://api-platform.com/docs/core/filters/#doctrine-orm-and-mongodb-odm-filters |
||
225 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
226 | * |
||
227 | * @var string[] |
||
228 | */ |
||
229 | private $filters; |
||
230 | |||
231 | /** |
||
232 | * @see https://api-platform.com/docs/core/extending-jsonld-context/#hydra |
||
233 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
234 | * |
||
235 | * @var string[] |
||
236 | */ |
||
237 | private $hydraContext; |
||
0 ignored issues
–
show
|
|||
238 | |||
239 | /** |
||
240 | * @see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation |
||
241 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
242 | * |
||
243 | * @var string|false |
||
244 | */ |
||
245 | private $input; |
||
246 | |||
247 | /** |
||
248 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
249 | * |
||
250 | * @var int |
||
251 | * |
||
252 | * @deprecated - Use $paginationMaximumItemsPerPage instead |
||
253 | */ |
||
254 | private $maximumItemsPerPage; |
||
255 | |||
256 | /** |
||
257 | * @see https://api-platform.com/docs/core/mercure |
||
258 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
259 | * |
||
260 | * @var mixed |
||
261 | */ |
||
262 | private $mercure; |
||
0 ignored issues
–
show
|
|||
263 | |||
264 | /** |
||
265 | * @see https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus |
||
266 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
267 | * |
||
268 | * @var bool|string |
||
269 | */ |
||
270 | private $messenger; |
||
0 ignored issues
–
show
|
|||
271 | |||
272 | /** |
||
273 | * @see https://api-platform.com/docs/core/serialization/#using-serialization-groups |
||
274 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
275 | * |
||
276 | * @var array |
||
277 | */ |
||
278 | private $normalizationContext; |
||
279 | |||
280 | /** |
||
281 | * @see https://api-platform.com/docs/core/swagger/#using-the-openapi-and-swagger-contexts |
||
282 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
283 | * |
||
284 | * @var array |
||
285 | */ |
||
286 | private $openapiContext; |
||
0 ignored issues
–
show
|
|||
287 | |||
288 | /** |
||
289 | * @see https://api-platform.com/docs/core/default-order/#overriding-default-order |
||
290 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
291 | * |
||
292 | * @var array |
||
293 | */ |
||
294 | private $order; |
||
295 | |||
296 | /** |
||
297 | * @see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation |
||
298 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
299 | * |
||
300 | * @var string|false |
||
301 | */ |
||
302 | private $output; |
||
0 ignored issues
–
show
|
|||
303 | |||
304 | /** |
||
305 | * @see https://api-platform.com/docs/core/pagination/#for-a-specific-resource-1 |
||
306 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
307 | * |
||
308 | * @var bool |
||
309 | */ |
||
310 | private $paginationClientEnabled; |
||
311 | |||
312 | /** |
||
313 | * @see https://api-platform.com/docs/core/pagination/#for-a-specific-resource-3 |
||
314 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
315 | * |
||
316 | * @var bool |
||
317 | */ |
||
318 | private $paginationClientItemsPerPage; |
||
319 | |||
320 | /** |
||
321 | * @see https://api-platform.com/docs/core/pagination/#for-a-specific-resource-6 |
||
322 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
323 | * |
||
324 | * @var bool |
||
325 | */ |
||
326 | private $paginationClientPartial; |
||
327 | |||
328 | /** |
||
329 | * @see https://api-platform.com/docs/core/pagination/#cursor-based-pagination |
||
330 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
331 | * |
||
332 | * @var array |
||
333 | */ |
||
334 | private $paginationViaCursor; |
||
335 | |||
336 | /** |
||
337 | * @see https://api-platform.com/docs/core/pagination/#for-a-specific-resource |
||
338 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
339 | * |
||
340 | * @var bool |
||
341 | */ |
||
342 | private $paginationEnabled; |
||
343 | |||
344 | /** |
||
345 | * @see https://api-platform.com/docs/core/pagination/#controlling-the-behavior-of-the-doctrine-orm-paginator |
||
346 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
347 | * |
||
348 | * @var bool |
||
349 | */ |
||
350 | private $paginationFetchJoinCollection; |
||
351 | |||
352 | /** |
||
353 | * @see https://api-platform.com/docs/core/pagination/#changing-the-number-of-items-per-page |
||
354 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
355 | * |
||
356 | * @var int |
||
357 | */ |
||
358 | private $paginationItemsPerPage; |
||
359 | |||
360 | /** |
||
361 | * @see https://api-platform.com/docs/core/pagination/#changing-maximum-items-per-page |
||
362 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
363 | * |
||
364 | * @var int |
||
365 | */ |
||
366 | private $paginationMaximumItemsPerPage; |
||
367 | |||
368 | /** |
||
369 | * @see https://api-platform.com/docs/core/performance/#partial-pagination |
||
370 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
371 | * |
||
372 | * @var int |
||
373 | */ |
||
374 | private $paginationPartial; |
||
375 | |||
376 | /** |
||
377 | * @see https://api-platform.com/docs/core/operations/#prefixing-all-routes-of-all-operations |
||
378 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
379 | * |
||
380 | * @var string |
||
381 | */ |
||
382 | private $routePrefix; |
||
383 | |||
384 | /** |
||
385 | * @see https://api-platform.com/docs/core/security |
||
386 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
387 | * |
||
388 | * @var string |
||
389 | */ |
||
390 | private $security; |
||
0 ignored issues
–
show
|
|||
391 | |||
392 | /** |
||
393 | * @see https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message |
||
394 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
395 | * |
||
396 | * @var string |
||
397 | */ |
||
398 | private $securityMessage; |
||
0 ignored issues
–
show
|
|||
399 | |||
400 | /** |
||
401 | * @see https://api-platform.com/docs/core/security/#executing-access-control-rules-after-denormalization |
||
402 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
403 | * |
||
404 | * @var string |
||
405 | */ |
||
406 | private $securityPostDenormalize; |
||
407 | |||
408 | /** |
||
409 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
410 | * |
||
411 | * @var string |
||
412 | */ |
||
413 | private $securityPostDenormalizeMessage; |
||
414 | |||
415 | /** |
||
416 | * @see https://api-platform.com/docs/core/deprecations/#setting-the-sunset-http-header-to-indicate-when-a-resource-or-an-operation-will-be-removed |
||
417 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
418 | * |
||
419 | * @var string |
||
420 | */ |
||
421 | private $sunset; |
||
0 ignored issues
–
show
|
|||
422 | |||
423 | /** |
||
424 | * @see https://api-platform.com/docs/core/swagger/#using-the-openapi-and-swagger-contexts |
||
425 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
426 | * |
||
427 | * @var array |
||
428 | */ |
||
429 | private $swaggerContext; |
||
0 ignored issues
–
show
|
|||
430 | |||
431 | /** |
||
432 | * @see https://api-platform.com/docs/core/validation/#using-validation-groups |
||
433 | * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
||
434 | * |
||
435 | * @var mixed |
||
436 | */ |
||
437 | private $validationGroups; |
||
438 | |||
439 | /** |
||
440 | * @throws InvalidArgumentException |
||
441 | */ |
||
442 | public function __construct(array $values = []) |
||
443 | { |
||
444 | $this->hydrateAttributes($values); |
||
445 | } |
||
446 | } |
||
447 |