Issues (332)

src/Annotation/ApiResource.php (5 issues)

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;
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;
0 ignored issues
show
The private property $deprecationReason is not used, and could be removed.
Loading history...
191
192
    /**
193
     * @see https://api-platform.com/docs/core/elasticsearch/
194
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
195
     *
196
     * @var bool
197
     */
198
    private $elasticsearch;
199
200
    /**
201
     * @see https://api-platform.com/docs/core/performance/#fetch-partial
202
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
203
     *
204
     * @var bool
205
     */
206
    private $fetchPartial;
207
208
    /**
209
     * @see https://api-platform.com/docs/core/performance/#force-eager
210
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
211
     *
212
     * @var bool
213
     */
214
    private $forceEager;
215
216
    /**
217
     * @see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
218
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
219
     *
220
     * @var array
221
     */
222
    private $formats;
223
224
    /**
225
     * @see https://api-platform.com/docs/core/filters/#doctrine-orm-and-mongodb-odm-filters
226
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
227
     *
228
     * @var string[]
229
     */
230
    private $filters;
231
232
    /**
233
     * @see https://api-platform.com/docs/core/extending-jsonld-context/#hydra
234
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
235
     *
236
     * @var string[]
237
     */
238
    private $hydraContext;
0 ignored issues
show
The private property $hydraContext is not used, and could be removed.
Loading history...
239
240
    /**
241
     * @see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation
242
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
243
     *
244
     * @var string|false
245
     */
246
    private $input;
247
248
    /**
249
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
250
     *
251
     * @var int
252
     *
253
     * @deprecated - Use $paginationMaximumItemsPerPage instead
254
     */
255
    private $maximumItemsPerPage;
256
257
    /**
258
     * @see https://api-platform.com/docs/core/mercure
259
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
260
     *
261
     * @var mixed
262
     */
263
    private $mercure;
0 ignored issues
show
The private property $mercure is not used, and could be removed.
Loading history...
264
265
    /**
266
     * @see https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus
267
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
268
     *
269
     * @var bool|string
270
     */
271
    private $messenger;
0 ignored issues
show
The private property $messenger is not used, and could be removed.
Loading history...
272
273
    /**
274
     * @see https://api-platform.com/docs/core/serialization/#using-serialization-groups
275
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
276
     *
277
     * @var array
278
     */
279
    private $normalizationContext;
280
281
    /**
282
     * @see https://api-platform.com/docs/core/swagger/#using-the-openapi-and-swagger-contexts
283
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
284
     *
285
     * @var array
286
     */
287
    private $openapiContext;
288
289
    /**
290
     * @see https://api-platform.com/docs/core/default-order/#overriding-default-order
291
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
292
     *
293
     * @var array
294
     */
295
    private $order;
296
297
    /**
298
     * @see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation
299
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
300
     *
301
     * @var string|false
302
     */
303
    private $output;
304
305
    /**
306
     * @see https://api-platform.com/docs/core/pagination/#for-a-specific-resource-1
307
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
308
     *
309
     * @var bool
310
     */
311
    private $paginationClientEnabled;
312
313
    /**
314
     * @see https://api-platform.com/docs/core/pagination/#for-a-specific-resource-3
315
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
316
     *
317
     * @var bool
318
     */
319
    private $paginationClientItemsPerPage;
320
321
    /**
322
     * @see https://api-platform.com/docs/core/pagination/#for-a-specific-resource-6
323
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
324
     *
325
     * @var bool
326
     */
327
    private $paginationClientPartial;
328
329
    /**
330
     * @see https://api-platform.com/docs/core/pagination/#cursor-based-pagination
331
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
332
     *
333
     * @var array
334
     */
335
    private $paginationViaCursor;
336
337
    /**
338
     * @see https://api-platform.com/docs/core/pagination/#for-a-specific-resource
339
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
340
     *
341
     * @var bool
342
     */
343
    private $paginationEnabled;
344
345
    /**
346
     * @see https://api-platform.com/docs/core/pagination/#controlling-the-behavior-of-the-doctrine-orm-paginator
347
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
348
     *
349
     * @var bool
350
     */
351
    private $paginationFetchJoinCollection;
352
353
    /**
354
     * @see https://api-platform.com/docs/core/pagination/#changing-the-number-of-items-per-page
355
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
356
     *
357
     * @var int
358
     */
359
    private $paginationItemsPerPage;
360
361
    /**
362
     * @see https://api-platform.com/docs/core/pagination/#changing-maximum-items-per-page
363
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
364
     *
365
     * @var int
366
     */
367
    private $paginationMaximumItemsPerPage;
368
369
    /**
370
     * @see https://api-platform.com/docs/core/performance/#partial-pagination
371
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
372
     *
373
     * @var bool
374
     */
375
    private $paginationPartial;
376
377
    /**
378
     * @see https://api-platform.com/docs/core/operations/#prefixing-all-routes-of-all-operations
379
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
380
     *
381
     * @var string
382
     */
383
    private $routePrefix;
384
385
    /**
386
     * @see https://api-platform.com/docs/core/security
387
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
388
     *
389
     * @var string
390
     */
391
    private $security;
392
393
    /**
394
     * @see https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message
395
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
396
     *
397
     * @var string
398
     */
399
    private $securityMessage;
400
401
    /**
402
     * @see https://api-platform.com/docs/core/security/#executing-access-control-rules-after-denormalization
403
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
404
     *
405
     * @var string
406
     */
407
    private $securityPostDenormalize;
408
409
    /**
410
     * @see https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message
411
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
412
     *
413
     * @var string
414
     */
415
    private $securityPostDenormalizeMessage;
416
417
    /**
418
     * @see https://api-platform.com/docs/core/deprecations/#setting-the-sunset-http-header-to-indicate-when-a-resource-or-an-operation-will-be-removed
419
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
420
     *
421
     * @var string
422
     */
423
    private $sunset;
424
425
    /**
426
     * @see https://api-platform.com/docs/core/swagger/#using-the-openapi-and-swagger-contexts
427
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
428
     *
429
     * @var array
430
     */
431
    private $swaggerContext;
432
433
    /**
434
     * @see https://api-platform.com/docs/core/validation/#using-validation-groups
435
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
436
     *
437
     * @var mixed
438
     */
439
    private $validationGroups;
0 ignored issues
show
The private property $validationGroups is not used, and could be removed.
Loading history...
440
441
    /**
442
     * @throws InvalidArgumentException
443
     */
444
    public function __construct(array $values = [])
445
    {
446
        $this->hydrateAttributes($values);
447
    }
448
}
449