Completed
Push — master ( 3c371a...480c07 )
by Antoine
23s queued 14s
created

src/Annotation/ApiResource.php (1 issue)

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
     * @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
     * @var string
127
     */
128
    public $shortName;
129
130
    /**
131
     * @var string
132
     */
133
    public $description;
134
135
    /**
136
     * @var string
137
     */
138
    public $iri;
139
140
    /**
141
     * @var array
142
     */
143
    public $itemOperations;
144
145
    /**
146
     * @var array
147
     */
148
    public $collectionOperations;
149
150
    /**
151
     * @var array
152
     */
153
    public $subresourceOperations;
154
155
    /**
156
     * @var array
157
     */
158
    public $graphql;
159
160
    /**
161
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
162
     *
163
     * @var string
164
     */
165
    private $security;
166
167
    /**
168
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
169
     *
170
     * @var string
171
     */
172
    private $securityMessage;
173
174
    /**
175
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
176
     *
177
     * @var string
178
     */
179
    private $securityPostDenormalize;
180
181
    /**
182
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
183
     *
184
     * @var string
185
     */
186
    private $securityPostDenormalizeMessage;
187
188
    /**
189
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
190
     *
191
     * @var array
192
     */
193
    private $cacheHeaders;
194
195
    /**
196
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
197
     *
198
     * @var array
199
     */
200
    private $denormalizationContext;
201
202
    /**
203
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
204
     *
205
     * @var string
206
     */
207
    private $deprecationReason;
208
209
    /**
210
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
211
     *
212
     * @var bool
213
     */
214
    private $elasticsearch;
215
216
    /**
217
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
218
     *
219
     * @var bool
220
     */
221
    private $fetchPartial;
222
223
    /**
224
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
225
     *
226
     * @var bool
227
     */
228
    private $forceEager;
229
230
    /**
231
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
232
     *
233
     * @var array
234
     */
235
    private $formats;
236
237
    /**
238
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
239
     *
240
     * @var string[]
241
     */
242
    private $filters;
243
244
    /**
245
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
246
     *
247
     * @var string[]
248
     */
249
    private $hydraContext;
250
251
    /**
252
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
253
     *
254
     * @var mixed
255
     */
256
    private $mercure;
257
258
    /**
259
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
260
     *
261
     * @var bool|string
262
     */
263
    private $messenger;
264
265
    /**
266
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
267
     *
268
     * @var array
269
     */
270
    private $normalizationContext;
271
272
    /**
273
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
274
     *
275
     * @var array
276
     */
277
    private $order;
278
279
    /**
280
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
281
     *
282
     * @var bool
283
     */
284
    private $paginationClientEnabled;
285
286
    /**
287
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
288
     *
289
     * @var bool
290
     */
291
    private $paginationClientItemsPerPage;
292
293
    /**
294
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
295
     *
296
     * @var bool
297
     */
298
    private $paginationClientPartial;
299
300
    /**
301
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
302
     *
303
     * @var bool
304
     */
305
    private $paginationEnabled;
306
307
    /**
308
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
309
     *
310
     * @var bool
311
     */
312
    private $paginationFetchJoinCollection;
313
314
    /**
315
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
316
     *
317
     * @var int
318
     */
319
    private $paginationItemsPerPage;
320
321
    /**
322
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
323
     *
324
     * @var int
325
     *
326
     * @deprecated - Use $paginationMaximumItemsPerPage instead
327
     */
328
    private $maximumItemsPerPage;
329
330
    /**
331
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
332
     *
333
     * @var int
334
     */
335
    private $paginationMaximumItemsPerPage;
0 ignored issues
show
The private property $paginationMaximumItemsPerPage is not used, and could be removed.
Loading history...
336
337
    /**
338
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
339
     *
340
     * @var int
341
     */
342
    private $paginationPartial;
343
344
    /**
345
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
346
     *
347
     * @var string
348
     */
349
    private $routePrefix;
350
351
    /**
352
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
353
     *
354
     * @var array
355
     */
356
    private $swaggerContext;
357
358
    /**
359
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
360
     *
361
     * @var mixed
362
     */
363
    private $validationGroups;
364
365
    /**
366
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
367
     *
368
     * @var string
369
     */
370
    private $sunset;
371
372
    /**
373
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
374
     *
375
     * @var string|false
376
     */
377
    private $input;
378
379
    /**
380
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
381
     *
382
     * @var string|false
383
     */
384
    private $output;
385
386
    /**
387
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
388
     *
389
     * @var array
390
     */
391
    private $openapiContext;
392
393
    /**
394
     * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
395
     *
396
     * @var array
397
     */
398
    private $paginationViaCursor;
399
400
    /**
401
     * @throws InvalidArgumentException
402
     */
403
    public function __construct(array $values = [])
404
    {
405
        $this->hydrateAttributes($values);
406
    }
407
}
408