-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HttpOperation.php
601 lines (513 loc) · 17.9 KB
/
HttpOperation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
<?php
/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace ApiPlatform\Metadata;
use ApiPlatform\OpenApi\Model\Operation as OpenApiOperation;
use ApiPlatform\State\OptionsInterface;
class HttpOperation extends Operation
{
public const METHOD_GET = 'GET';
public const METHOD_POST = 'POST';
public const METHOD_PUT = 'PUT';
public const METHOD_PATCH = 'PATCH';
public const METHOD_DELETE = 'DELETE';
public const METHOD_HEAD = 'HEAD';
public const METHOD_OPTIONS = 'OPTIONS';
/**
* @param string[]|null $types the RDF types of this property
* @param array<int|string, string|string[]>|string|null $formats {@see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation}
* @param array<int|string, string|string[]>|string|null $inputFormats {@see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation}
* @param array<int|string, string|string[]>|string|null $outputFormats {@see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation}
* @param array<string,array{
* 0: string,
* 1: string
* }|array{
* from_property?: string,
* to_property?: string,
* from_class?: string,
* to_class?: string,
* identifiers?: string[],
* composite_identifier?: bool,
* expanded_value?: string,
* }|Link>|string[]|string|null $uriVariables {@see https://api-platform.com/docs/core/subresources/}
* @param string|null $routePrefix {@see https://api-platform.com/docs/core/operations/#prefixing-all-routes-of-all-operations}
* @param string|null $sunset {@see https://api-platform.com/docs/core/deprecations/#setting-the-sunset-http-header-to-indicate-when-a-resource-or-an-operation-will-be-removed}
* @param string|int|null $status {@see https://api-platform.com/docs/core/operations/#configuring-operations}
* @param array{
* max_age?: int,
* vary?: string|string[],
* public?: bool,
* shared_max_age?: int,
* stale_while_revalidate?: int,
* stale-if-error?: int,
* }|null $cacheHeaders {@see https://api-platform.com/docs/core/performance/#setting-custom-http-cache-headers}
* @param array{
* field: string,
* direction: string,
* }|null $paginationViaCursor {@see https://api-platform.com/docs/core/pagination/#cursor-based-pagination}
* @param array|null $normalizationContext {@see https://api-platform.com/docs/core/serialization/#using-serialization-groups}
* @param array|null $denormalizationContext {@see https://api-platform.com/docs/core/serialization/#using-serialization-groups}
* @param array|null $hydraContext {@see https://api-platform.com/docs/core/extending-jsonld-context/#hydra}
* @param array|null $openapiContext {@see https://api-platform.com/docs/core/openapi/#using-the-openapi-and-swagger-contexts}
* @param array{
* class?: string|null,
* name?: string,
* }|string|false|null $input {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation}
* @param array{
* class?: string|null,
* name?: string,
* }|string|false|null $output {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation}
* @param string|array|bool|null $mercure {@see https://api-platform.com/docs/core/mercure}
* @param string|bool|null $messenger {@see https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus}
* @param string|callable|null $provider {@see https://api-platform.com/docs/core/state-providers/#state-providers}
* @param string|callable|null $processor {@see https://api-platform.com/docs/core/state-processors/#state-processors}
*/
public function __construct(
protected string $method = self::METHOD_GET,
protected ?string $uriTemplate = null,
protected ?array $types = null,
protected $formats = null,
protected $inputFormats = null,
protected $outputFormats = null,
protected $uriVariables = null,
protected ?string $routePrefix = null,
protected ?string $routeName = null,
protected ?array $defaults = null,
protected ?array $requirements = null,
protected ?array $options = null,
protected ?bool $stateless = null,
/**
* The `sunset` option indicates when a deprecated operation will be removed.
*
* <div data-code-selector>
*
* ```php
* <?php
* // api/src/Entity/Parchment.php
* use ApiPlatform\Metadata\Get;
*
* #[Get(deprecationReason: 'Create a Book instead', sunset: '01/01/2020')]
* class Parchment
* {
* // ...
* }
* ```
*
* ```yaml
* # api/config/api_platform/resources.yaml
* resources:
* App\Entity\Parchment:
* - operations:
* ApiPlatform\Metadata\Get:
* deprecationReason: 'Create a Book instead'
* sunset: '01/01/2020'
* ```
*
* ```xml
* <?xml version="1.0" encoding="UTF-8" ?>
* <!-- api/config/api_platform/resources.xml -->
*
* <resources
* xmlns="https://api-platform.com/schema/metadata/resources-3.0"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
* https://api-platform.com/schema/metadata/resources-3.0.xsd">
* <resource class="App\Entity\Parchment">
* <operations>
* <operation class="ApiPlatform\Metadata\Get" deprecationReason="Create a Book instead" sunset="01/01/2020" />
* <operations>
* </resource>
* </resources>
* ```
*
* </div>
*/
protected ?string $sunset = null,
protected ?string $acceptPatch = null,
protected $status = null,
protected ?string $host = null,
protected ?array $schemes = null,
protected ?string $condition = null,
protected ?string $controller = null,
protected ?array $cacheHeaders = null,
protected ?array $paginationViaCursor = null,
protected ?array $hydraContext = null,
protected ?array $openapiContext = null, // TODO Remove in 4.0
protected bool|OpenApiOperation|null $openapi = null,
protected ?array $exceptionToStatus = null,
protected ?bool $queryParameterValidationEnabled = null,
?string $shortName = null,
?string $class = null,
?bool $paginationEnabled = null,
?string $paginationType = null,
?int $paginationItemsPerPage = null,
?int $paginationMaximumItemsPerPage = null,
?bool $paginationPartial = null,
?bool $paginationClientEnabled = null,
?bool $paginationClientItemsPerPage = null,
?bool $paginationClientPartial = null,
?bool $paginationFetchJoinCollection = null,
?bool $paginationUseOutputWalkers = null,
?array $order = null,
?string $description = null,
?array $normalizationContext = null,
?array $denormalizationContext = null,
?bool $collectDenormalizationErrors = null,
?string $security = null,
?string $securityMessage = null,
?string $securityPostDenormalize = null,
?string $securityPostDenormalizeMessage = null,
?string $securityPostValidation = null,
?string $securityPostValidationMessage = null,
?string $deprecationReason = null,
?array $filters = null,
?array $validationContext = null,
$input = null,
$output = null,
$mercure = null,
$messenger = null,
?bool $elasticsearch = null,
?int $urlGenerationStrategy = null,
?bool $read = null,
?bool $deserialize = null,
?bool $validate = null,
?bool $write = null,
?bool $serialize = null,
?bool $fetchPartial = null,
?bool $forceEager = null,
?int $priority = null,
?string $name = null,
$provider = null,
$processor = null,
?OptionsInterface $stateOptions = null,
array $extraProperties = [],
) {
parent::__construct(
shortName: $shortName,
class: $class,
paginationEnabled: $paginationEnabled,
paginationType: $paginationType,
paginationItemsPerPage: $paginationItemsPerPage,
paginationMaximumItemsPerPage: $paginationMaximumItemsPerPage,
paginationPartial: $paginationPartial,
paginationClientEnabled: $paginationClientEnabled,
paginationClientItemsPerPage: $paginationClientItemsPerPage,
paginationClientPartial: $paginationClientPartial,
paginationFetchJoinCollection: $paginationFetchJoinCollection,
paginationUseOutputWalkers: $paginationUseOutputWalkers,
order: $order,
description: $description,
normalizationContext: $normalizationContext,
denormalizationContext: $denormalizationContext,
collectDenormalizationErrors: $collectDenormalizationErrors,
security: $security,
securityMessage: $securityMessage,
securityPostDenormalize: $securityPostDenormalize,
securityPostDenormalizeMessage: $securityPostDenormalizeMessage,
securityPostValidation: $securityPostValidation,
securityPostValidationMessage: $securityPostValidationMessage,
deprecationReason: $deprecationReason,
filters: $filters,
validationContext: $validationContext,
input: $input,
output: $output,
mercure: $mercure,
messenger: $messenger,
elasticsearch: $elasticsearch,
urlGenerationStrategy: $urlGenerationStrategy,
read: $read,
deserialize: $deserialize,
validate: $validate,
write: $write,
serialize: $serialize,
fetchPartial: $fetchPartial,
forceEager: $forceEager,
priority: $priority,
name: $name,
provider: $provider,
processor: $processor,
stateOptions: $stateOptions,
extraProperties: $extraProperties
);
}
public function getMethod(): string
{
return $this->method;
}
public function withMethod(string $method): self
{
$self = clone $this;
$self->method = $method;
return $self;
}
public function getUriTemplate(): ?string
{
return $this->uriTemplate;
}
public function withUriTemplate(?string $uriTemplate = null)
{
$self = clone $this;
$self->uriTemplate = $uriTemplate;
return $self;
}
public function getTypes(): ?array
{
return $this->types;
}
/**
* @param string[]|string $types
*/
public function withTypes($types): self
{
$self = clone $this;
$self->types = (array) $types;
return $self;
}
public function getFormats()
{
return $this->formats;
}
public function withFormats($formats = null): self
{
$self = clone $this;
$self->formats = $formats;
return $self;
}
public function getInputFormats()
{
return $this->inputFormats;
}
public function withInputFormats($inputFormats = null): self
{
$self = clone $this;
$self->inputFormats = $inputFormats;
return $self;
}
public function getOutputFormats()
{
return $this->outputFormats;
}
public function withOutputFormats($outputFormats = null): self
{
$self = clone $this;
$self->outputFormats = $outputFormats;
return $self;
}
public function getUriVariables()
{
return $this->uriVariables;
}
public function withUriVariables($uriVariables): self
{
$self = clone $this;
$self->uriVariables = $uriVariables;
return $self;
}
public function getRoutePrefix(): ?string
{
return $this->routePrefix;
}
public function withRoutePrefix(string $routePrefix): self
{
$self = clone $this;
$self->routePrefix = $routePrefix;
return $self;
}
public function getRouteName(): ?string
{
return $this->routeName;
}
public function withRouteName(?string $routeName): self
{
$self = clone $this;
$self->routeName = $routeName;
return $self;
}
public function getDefaults(): ?array
{
return $this->defaults;
}
public function withDefaults(array $defaults): self
{
$self = clone $this;
$self->defaults = $defaults;
return $self;
}
public function getRequirements(): ?array
{
return $this->requirements;
}
public function withRequirements(array $requirements): self
{
$self = clone $this;
$self->requirements = $requirements;
return $self;
}
public function getOptions(): ?array
{
return $this->options;
}
public function withOptions(array $options): self
{
$self = clone $this;
$self->options = $options;
return $self;
}
public function getStateless(): ?bool
{
return $this->stateless;
}
public function withStateless($stateless): self
{
$self = clone $this;
$self->stateless = $stateless;
return $self;
}
public function getSunset(): ?string
{
return $this->sunset;
}
public function withSunset(string $sunset): self
{
$self = clone $this;
$self->sunset = $sunset;
return $self;
}
public function getAcceptPatch(): ?string
{
return $this->acceptPatch;
}
public function withAcceptPatch(string $acceptPatch): self
{
$self = clone $this;
$self->acceptPatch = $acceptPatch;
return $self;
}
public function getStatus(): ?int
{
return $this->status;
}
public function withStatus(int $status): self
{
$self = clone $this;
$self->status = $status;
return $self;
}
public function getHost(): ?string
{
return $this->host;
}
public function withHost(string $host): self
{
$self = clone $this;
$self->host = $host;
return $self;
}
public function getSchemes(): ?array
{
return $this->schemes;
}
public function withSchemes(array $schemes): self
{
$self = clone $this;
$self->schemes = $schemes;
return $self;
}
public function getCondition(): ?string
{
return $this->condition;
}
public function withCondition(string $condition): self
{
$self = clone $this;
$self->condition = $condition;
return $self;
}
public function getController(): ?string
{
return $this->controller;
}
public function withController(string $controller): self
{
$self = clone $this;
$self->controller = $controller;
return $self;
}
public function getCacheHeaders(): ?array
{
return $this->cacheHeaders;
}
public function withCacheHeaders(array $cacheHeaders): self
{
$self = clone $this;
$self->cacheHeaders = $cacheHeaders;
return $self;
}
public function getPaginationViaCursor(): ?array
{
return $this->paginationViaCursor;
}
public function withPaginationViaCursor(array $paginationViaCursor): self
{
$self = clone $this;
$self->paginationViaCursor = $paginationViaCursor;
return $self;
}
public function getHydraContext(): ?array
{
return $this->hydraContext;
}
public function withHydraContext(array $hydraContext): self
{
$self = clone $this;
$self->hydraContext = $hydraContext;
return $self;
}
public function getOpenapiContext(): ?array
{
return $this->openapiContext;
}
public function withOpenapiContext(array $openapiContext): self
{
$self = clone $this;
$self->openapiContext = $openapiContext;
return $self;
}
public function getOpenapi(): bool|OpenApiOperation|null
{
return $this->openapi;
}
public function withOpenapi(bool|OpenApiOperation $openapi): self
{
$self = clone $this;
$self->openapi = $openapi;
return $self;
}
public function getExceptionToStatus(): ?array
{
return $this->exceptionToStatus;
}
public function withExceptionToStatus(array $exceptionToStatus): self
{
$self = clone $this;
$self->exceptionToStatus = $exceptionToStatus;
return $self;
}
public function getQueryParameterValidationEnabled(): ?bool
{
return $this->queryParameterValidationEnabled;
}
public function withQueryParameterValidationEnabled(bool $queryParameterValidationEnabled): self
{
$self = clone $this;
$self->queryParameterValidationEnabled = $queryParameterValidationEnabled;
return $self;
}
}