• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 15133993414

20 May 2025 09:30AM UTC coverage: 26.313% (-1.2%) from 27.493%
15133993414

Pull #7161

github

web-flow
Merge e2c03d45f into 5459ba375
Pull Request #7161: fix(metadata): infer parameter string type from schema

0 of 2 new or added lines in 1 file covered. (0.0%)

11019 existing lines in 363 files now uncovered.

12898 of 49018 relevant lines covered (26.31%)

34.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.68
/src/Metadata/Operation.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
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\Metadata;
15

16
use ApiPlatform\State\OptionsInterface;
17

18
/**
19
 * âš  This class and its children offer no backward compatibility regarding positional parameters.
20
 */
21
abstract class Operation extends Metadata
22
{
23
    use WithResourceTrait;
24

25
    /**
26
     * @param bool|null                           $paginationEnabled              {@see https://api-platform.com/docs/core/pagination/#for-a-specific-resource}
27
     * @param string|null                         $paginationType                 {@see https://api-platform.com/docs/core/graphql/#using-the-page-based-pagination}
28
     * @param int|null                            $paginationItemsPerPage         {@see https://api-platform.com/docs/core/pagination/#changing-the-number-of-items-per-page}
29
     * @param int|null                            $paginationMaximumItemsPerPage  {@see https://api-platform.com/docs/core/pagination/#changing-maximum-items-per-page}
30
     * @param bool|null                           $paginationPartial              {@see https://api-platform.com/docs/core/performance/#partial-pagination}
31
     * @param bool|null                           $paginationClientEnabled        {@see https://api-platform.com/docs/core/pagination/#for-a-specific-resource-1}
32
     * @param bool|null                           $paginationClientItemsPerPage   {@see https://api-platform.com/docs/core/pagination/#for-a-specific-resource-3}
33
     * @param bool|null                           $paginationClientPartial        {@see https://api-platform.com/docs/core/pagination/#for-a-specific-resource-6}
34
     * @param bool|null                           $paginationFetchJoinCollection  {@see https://api-platform.com/docs/core/pagination/#controlling-the-behavior-of-the-doctrine-orm-paginator}
35
     * @param array<string, string>|string[]|null $order                          {@see https://api-platform.com/docs/core/default-order/#overriding-default-order}
36
     * @param string|null                         $security                       {@see https://api-platform.com/docs/core/security}
37
     * @param string|null                         $securityMessage                {@see https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message}
38
     * @param string|null                         $securityPostDenormalize        {@see https://api-platform.com/docs/core/security/#executing-access-control-rules-after-denormalization}
39
     * @param string|null                         $securityPostDenormalizeMessage {@see https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message}
40
     * @param string|null                         $deprecationReason              {@see https://api-platform.com/docs/core/deprecations/#deprecating-resource-classes-operations-and-properties}
41
     * @param string[]|null                       $filters                        {@see https://api-platform.com/docs/core/filters/#doctrine-orm-and-mongodb-odm-filters}
42
     * @param array{
43
     *     class?: string|null,
44
     *     name?: string,
45
     * }|string|false|null $input {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation}
46
     * @param array{
47
     *     class?: string|null,
48
     *     name?: string,
49
     * }|string|false|null $output {@see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation}
50
     * @param string|array|bool|null   $mercure       {@see https://api-platform.com/docs/core/mercure}
51
     * @param string|bool|null         $messenger     {@see https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus}
52
     * @param bool|null                $elasticsearch {@see https://api-platform.com/docs/core/elasticsearch/}
53
     * @param bool|null                $read          {@see https://api-platform.com/docs/core/events/#the-event-system}
54
     * @param bool|null                $deserialize   {@see https://api-platform.com/docs/core/events/#the-event-system}
55
     * @param bool|null                $validate      {@see https://api-platform.com/docs/core/events/#the-event-system}
56
     * @param bool|null                $write         {@see https://api-platform.com/docs/core/events/#the-event-system}
57
     * @param bool|null                $serialize     {@see https://api-platform.com/docs/core/events/#the-event-system}
58
     * @param bool|null                $fetchPartial  {@see https://api-platform.com/docs/core/performance/#fetch-partial}
59
     * @param bool|null                $forceEager    {@see https://api-platform.com/docs/core/performance/#force-eager}
60
     * @param string|callable|null     $provider      {@see https://api-platform.com/docs/core/state-providers/#state-providers}
61
     * @param string|callable|null     $processor     {@see https://api-platform.com/docs/core/state-processors/#state-processors}
62
     * @param array<string, Parameter> $parameters
63
     */
64
    public function __construct(
65
        protected ?string $shortName = null,
66
        protected ?string $class = null,
67
        /**
68
         * The `paginationEnabled` option enables (or disables) the pagination for the current collection operation.
69
         *
70
         * <div data-code-selector>
71
         *
72
         * ```php
73
         * <?php
74
         * // api/src/Entity/Book.php
75
         * use ApiPlatform\Metadata\GetCollection;
76
         *
77
         * #[GetCollection(paginationEnabled: true)]
78
         * class Book
79
         * {
80
         *     // ...
81
         * }
82
         * ```
83
         *
84
         * ```yaml
85
         * # api/config/api_platform/resources.yaml
86
         * resources:
87
         *     App\Entity\Book:
88
         *         - operations:
89
         *               ApiPlatform\Metadata\GetCollection:
90
         *                   paginationEnabled: true
91
         * ```
92
         *
93
         * ```xml
94
         * <?xml version="1.0" encoding="UTF-8" ?>
95
         * <!-- api/config/api_platform/resources.xml -->
96
         *
97
         * <resources
98
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
99
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
100
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
101
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
102
         *     <resource class="App\Entity\Book">
103
         *         <operations>
104
         *             <operation class="ApiPlatform\Metadata\GetCollection" paginationEnabled=true />
105
         *         </operations>
106
         *     </resource>
107
         * </resources>
108
         * ```
109
         *
110
         * </div>
111
         */
112
        protected ?bool $paginationEnabled = null,
113
        /**
114
         * The `paginationType` option defines the type of pagination (`page` or `cursor`) to use for the current collection operation.
115
         *
116
         * <div data-code-selector>
117
         *
118
         * ```php
119
         * <?php
120
         * // api/src/Entity/Book.php
121
         * use ApiPlatform\Metadata\GetCollection;
122
         *
123
         * #[GetCollection(paginationType: 'page')]
124
         * class Book
125
         * {
126
         *     // ...
127
         * }
128
         * ```
129
         *
130
         * ```yaml
131
         * # api/config/api_platform/resources.yaml
132
         * resources:
133
         *     App\Entity\Book:
134
         *         - operations:
135
         *               ApiPlatform\Metadata\GetCollection:
136
         *                   paginationType: page
137
         * ```
138
         *
139
         * ```xml
140
         * <?xml version="1.0" encoding="UTF-8" ?>
141
         * <!-- api/config/api_platform/resources.xml -->
142
         *
143
         * <resources
144
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
145
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
146
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
147
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
148
         *     <resource class="App\Entity\Book">
149
         *         <operations>
150
         *             <operation class="ApiPlatform\Metadata\GetCollection" paginationType="page" />
151
         *         </operations>
152
         *     </resource>
153
         * </resources>
154
         * ```
155
         *
156
         * </div>
157
         */
158
        protected ?string $paginationType = null,
159
        /**
160
         * The `paginationItemsPerPage` option defines the number of items per page for the current collection operation.
161
         *
162
         * <div data-code-selector>
163
         *
164
         * ```php
165
         * <?php
166
         * // api/src/Entity/Book.php
167
         * use ApiPlatform\Metadata\GetCollection;
168
         *
169
         * #[GetCollection(paginationItemsPerPage: 30)]
170
         * class Book
171
         * {
172
         *     // ...
173
         * }
174
         * ```
175
         *
176
         * ```yaml
177
         * # api/config/api_platform/resources.yaml
178
         * resources:
179
         *     App\Entity\Book:
180
         *         - operations:
181
         *               ApiPlatform\Metadata\GetCollection:
182
         *                   paginationItemsPerPage: 30
183
         * ```
184
         *
185
         * ```xml
186
         * <?xml version="1.0" encoding="UTF-8" ?>
187
         * <!-- api/config/api_platform/resources.xml -->
188
         * <resources
189
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
190
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
191
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
192
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
193
         *     <resource class="App\Entity\Book">
194
         *         <operations>
195
         *             <operation class="ApiPlatform\Metadata\GetCollection" paginationItemsPerPage=30 />
196
         *         </operations>
197
         *     </resource>
198
         * </resources>
199
         * ```
200
         *
201
         * </div>
202
         */
203
        protected ?int $paginationItemsPerPage = null,
204
        /**
205
         * The `paginationMaximumItemsPerPage` option defines the maximum number of items per page for the current resource.
206
         *
207
         * <div data-code-selector>
208
         *
209
         * ```php
210
         * <?php
211
         * // api/src/Entity/Book.php
212
         * use ApiPlatform\Metadata\GetCollection;
213
         *
214
         * #[GetCollection(paginationMaximumItemsPerPage: 50)]
215
         * class Book
216
         * {
217
         *     // ...
218
         * }
219
         * ```
220
         *
221
         * ```yaml
222
         * # api/config/api_platform/resources.yaml
223
         * resources:
224
         *     App\Entity\Book:
225
         *         - operations:
226
         *               ApiPlatform\Metadata\GetCollection:
227
         *                   paginationMaximumItemsPerPage: 50
228
         * ```
229
         *
230
         * ```xml
231
         * <?xml version="1.0" encoding="UTF-8" ?>
232
         * <!-- api/config/api_platform/resources.xml -->
233
         * <resources
234
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
235
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
236
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
237
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
238
         *     <resource class="App\Entity\Book">
239
         *         <operations>
240
         *             <operation class="ApiPlatform\Metadata\GetCollection" paginationMaximumItemsPerPage=50 />
241
         *         </operations>
242
         *     </resource>
243
         * </resources>
244
         * ```
245
         *
246
         * </div>
247
         */
248
        protected ?int $paginationMaximumItemsPerPage = null,
249
        /**
250
         * The `paginationPartial` option enables (or disables) the partial pagination for the current collection operation.
251
         *
252
         * <div data-code-selector>
253
         *
254
         * ```php
255
         * <?php
256
         * // api/src/Entity/Book.php
257
         * use ApiPlatform\Metadata\GetCollection;
258
         *
259
         * #[GetCollection(paginationPartial: true)]
260
         * class Book
261
         * {
262
         *     // ...
263
         * }
264
         * ```
265
         *
266
         * ```yaml
267
         * # api/config/api_platform/resources.yaml
268
         * resources:
269
         *     App\Entity\Book:
270
         *         - operations:
271
         *               ApiPlatform\Metadata\GetCollection:
272
         *                   paginationPartial: true
273
         * ```
274
         *
275
         * ```xml
276
         * <?xml version="1.0" encoding="UTF-8" ?>
277
         * <!-- api/config/api_platform/resources.xml -->
278
         * <resources
279
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
280
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
281
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
282
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
283
         *     <resource class="App\Entity\Book">
284
         *         <operations>
285
         *             <operation class="ApiPlatform\Metadata\GetCollection" paginationPartial=true />
286
         *         </operations>
287
         *     </resource>
288
         * </resources>
289
         * ```
290
         *
291
         * </div>
292
         */
293
        protected ?bool $paginationPartial = null,
294
        /**
295
         * The `paginationClientEnabled` option allows (or disallows) the client to enable (or disable) the pagination for the current collection operation.
296
         *
297
         * <div data-code-selector>
298
         *
299
         * ```php
300
         * <?php
301
         * // api/src/Entity/Book.php
302
         * use ApiPlatform\Metadata\GetCollection;
303
         *
304
         * #[GetCollection(paginationClientEnabled: true)]
305
         * class Book
306
         * {
307
         *     // ...
308
         * }
309
         * ```
310
         *
311
         * ```yaml
312
         * # api/config/api_platform/resources.yaml
313
         * resources:
314
         *     App\Entity\Book:
315
         *         - operations:
316
         *               ApiPlatform\Metadata\GetCollection:
317
         *                   paginationClientEnabled: true
318
         * ```
319
         *
320
         * ```xml
321
         * <?xml version="1.0" encoding="UTF-8" ?>
322
         * <!-- api/config/api_platform/resources.xml -->
323
         * <resources
324
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
325
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
326
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
327
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
328
         *     <resource class="App\Entity\Book">
329
         *         <operations>
330
         *             <operation class="ApiPlatform\Metadata\GetCollection" paginationClientEnabled=true />
331
         *         </operations>
332
         *     </resource>
333
         * </resources>
334
         * ```
335
         *
336
         * </div>
337
         *
338
         * The pagination can now be enabled (or disabled) by adding a query parameter named `pagination`:
339
         * - `GET /books?pagination=false`: disabled
340
         * - `GET /books?pagination=true`: enabled
341
         */
342
        protected ?bool $paginationClientEnabled = null,
343
        /**
344
         * The `paginationClientItemsPerPage` option allows (or disallows) the client to set the number of items per page for the current collection operation.
345
         *
346
         * <div data-code-selector>
347
         *
348
         * ```php
349
         * <?php
350
         * // api/src/Entity/Book.php
351
         * use ApiPlatform\Metadata\GetCollection;
352
         *
353
         * #[GetCollection(paginationClientItemsPerPage: true)]
354
         * class Book
355
         * {
356
         *     // ...
357
         * }
358
         * ```
359
         *
360
         * ```yaml
361
         * # api/config/api_platform/resources.yaml
362
         * resources:
363
         *     App\Entity\Book:
364
         *         - operations:
365
         *               ApiPlatform\Metadata\GetCollection:
366
         *                   paginationClientItemsPerPage: true
367
         * ```
368
         *
369
         * ```xml
370
         * <?xml version="1.0" encoding="UTF-8" ?>
371
         * <!-- api/config/api_platform/resources.xml -->
372
         * <resources
373
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
374
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
375
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
376
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
377
         *     <resource class="App\Entity\Book">
378
         *         <operations>
379
         *             <operation class="ApiPlatform\Metadata\GetCollection" paginationClientItemsPerPage=true />
380
         *         </operations>
381
         *     </resource>
382
         * </resources>
383
         * ```
384
         *
385
         * </div>
386
         *
387
         * The number of items can now be set by adding a query parameter named `itemsPerPage`:
388
         * - `GET /books?itemsPerPage=50`
389
         */
390
        protected ?bool $paginationClientItemsPerPage = null,
391
        /**
392
         * The `paginationClientPartial` option allows (or disallows) the client to enable (or disable) the partial pagination for the current collection operation.
393
         *
394
         * <div data-code-selector>
395
         *
396
         * ```php
397
         * <?php
398
         * // api/src/Entity/Book.php
399
         * use ApiPlatform\Metadata\GetCollection;
400
         *
401
         * #[GetCollection(paginationClientPartial: true)]
402
         * class Book
403
         * {
404
         *     // ...
405
         * }
406
         * ```
407
         *
408
         * ```yaml
409
         * # api/config/api_platform/resources.yaml
410
         * resources:
411
         *     App\Entity\Book:
412
         *         - operations:
413
         *               ApiPlatform\Metadata\GetCollection:
414
         *                   paginationClientPartial: true
415
         * ```
416
         *
417
         * ```xml
418
         * <?xml version="1.0" encoding="UTF-8" ?>
419
         * <!-- api/config/api_platform/resources.xml -->
420
         * <resources
421
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
422
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
423
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
424
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
425
         *     <resource class="App\Entity\Book">
426
         *         <operations>
427
         *             <operation class="ApiPlatform\Metadata\GetCollection" paginationClientPartial=true />
428
         *         </operations>
429
         *     </resource>
430
         * </resources>
431
         * ```
432
         *
433
         * </div>
434
         *
435
         * The partial pagination can now be enabled (or disabled) by adding a query parameter named `partial`:
436
         * - `GET /books?partial=false`: disabled
437
         * - `GET /books?partial=true`: enabled
438
         */
439
        protected ?bool $paginationClientPartial = null,
440
        /**
441
         * The PaginationExtension of API Platform performs some checks on the `QueryBuilder` to guess, in most common
442
         * cases, the correct values to use when configuring the Doctrine ORM Paginator: `$fetchJoinCollection`
443
         * argument, whether there is a join to a collection-valued association.
444
         *
445
         * When set to `true`, the Doctrine ORM Paginator will perform an additional query, in order to get the
446
         * correct number of results. You can configure this using the `paginationFetchJoinCollection` option:
447
         *
448
         * <div data-code-selector>
449
         *
450
         * ```php
451
         * <?php
452
         * // api/src/Entity/Book.php
453
         * use ApiPlatform\Metadata\GetCollection;
454
         *
455
         * #[GetCollection(paginationFetchJoinCollection: false)]
456
         * class Book
457
         * {
458
         *     // ...
459
         * }
460
         * ```
461
         *
462
         * ```yaml
463
         * # api/config/api_platform/resources.yaml
464
         * resources:
465
         *     App\Entity\Book:
466
         *         - operations:
467
         *               ApiPlatform\Metadata\GetCollection:
468
         *                   paginationFetchJoinCollection: false
469
         * ```
470
         *
471
         * ```xml
472
         * <?xml version="1.0" encoding="UTF-8" ?>
473
         * <!-- api/config/api_platform/resources.xml -->
474
         * <resources
475
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
476
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
477
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
478
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
479
         *     <resource class="App\Entity\Book">
480
         *         <operations>
481
         *             <operation class="ApiPlatform\Metadata\GetCollection" paginationFetchJoinCollection=false />
482
         *         </operations>
483
         *     </resource>
484
         * </resources>
485
         * ```
486
         *
487
         * </div>
488
         *
489
         * For more information, please see the [Pagination](https://www.doctrine-project.org/projects/doctrine-orm/en/current/tutorials/pagination.html) entry in the Doctrine ORM documentation.
490
         */
491
        protected ?bool $paginationFetchJoinCollection = null,
492
        /**
493
         * The PaginationExtension of API Platform performs some checks on the `QueryBuilder` to guess, in most common
494
         * cases, the correct values to use when configuring the Doctrine ORM Paginator: `$setUseOutputWalkers` setter,
495
         * whether to use output walkers.
496
         *
497
         * When set to `true`, the Doctrine ORM Paginator will use output walkers, which are compulsory for some types
498
         * of queries. You can configure this using the `paginationUseOutputWalkers` option:
499
         *
500
         * <div data-code-selector>
501
         *
502
         * ```php
503
         * <?php
504
         * // api/src/Entity/Book.php
505
         * use ApiPlatform\Metadata\GetCollection;
506
         *
507
         * #[GetCollection(paginationUseOutputWalkers: false)]
508
         * class Book
509
         * {
510
         *     // ...
511
         * }
512
         * ```
513
         *
514
         * ```yaml
515
         * # api/config/api_platform/resources.yaml
516
         * resources:
517
         *     App\Entity\Book:
518
         *         - operations:
519
         *               ApiPlatform\Metadata\GetCollection:
520
         *                   paginationUseOutputWalkers: false
521
         * ```
522
         *
523
         * ```xml
524
         * <?xml version="1.0" encoding="UTF-8" ?>
525
         * <!-- api/config/api_platform/resources.xml -->
526
         * <resources
527
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
528
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
529
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
530
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
531
         *     <resource class="App\Entity\Book">
532
         *         <operations>
533
         *             <operation class="ApiPlatform\Metadata\GetCollection" paginationUseOutputWalkers=false />
534
         *         </operations>
535
         *     </resource>
536
         * </resources>
537
         * ```
538
         *
539
         * </div>
540
         *
541
         * For more information, please see the [Pagination](https://www.doctrine-project.org/projects/doctrine-orm/en/current/tutorials/pagination.html) entry in the Doctrine ORM documentation.
542
         */
543
        protected ?bool $paginationUseOutputWalkers = null,
544
        /**
545
         * The `paginationViaCursor` option configures the cursor-based pagination for the current resource.
546
         * Select your unique sorted field as well as the direction you'll like the pagination to go via filters.
547
         * Note that for now you have to declare a `RangeFilter` and an `OrderFilter` on the property used for the cursor-based pagination:.
548
         *
549
         * <div data-code-selector>
550
         *
551
         * ```php
552
         * <?php
553
         * // api/src/Entity/Book.php
554
         * use ApiPlatform\Metadata\ApiFilter;
555
         * use ApiPlatform\Metadata\GetCollection;
556
         * use ApiPlatform\Doctrine\Odm\Filter\OrderFilter;
557
         * use ApiPlatform\Doctrine\Odm\Filter\RangeFilter;
558
         *
559
         * #[GetCollection(paginationPartial: true, paginationViaCursor: [['field' => 'id', 'direction' => 'DESC']])]
560
         * #[ApiFilter(RangeFilter::class, properties: ["id"])]
561
         * #[ApiFilter(OrderFilter::class, properties: ["id" => "DESC"])]
562
         * class Book
563
         * {
564
         *     // ...
565
         * }
566
         * ```
567
         *
568
         * ```yaml
569
         * # api/config/api_platform/resources.yaml
570
         * resources:
571
         *     App\Entity\Book:
572
         *         - operations:
573
         *               ApiPlatform\Metadata\GetCollection:
574
         *                   paginationPartial: true
575
         *                   paginationViaCursor:
576
         *                       - { field: 'id', direction: 'DESC' }
577
         *                   filters: [ 'app.filters.book.range', 'app.filters.book.order' ]
578
         * ```
579
         *
580
         * ```xml
581
         * <?xml version="1.0" encoding="UTF-8" ?>
582
         * <!-- api/config/api_platform/resources.xml -->
583
         *
584
         * <resources
585
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
586
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
587
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
588
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
589
         *     <resource class="App\Entity\Book">
590
         *         <operations>
591
         *             <operation class="ApiPlatform\Metadata\GetCollection" paginationPartial=true>
592
         *                 <filters>
593
         *                     <filter>app.filters.book.range</filter>
594
         *                     <filter>app.filters.book.order</filter>
595
         *                 </filters>
596
         *                 <paginationViaCursor>
597
         *                     <paginationField field="id" direction="DESC" />
598
         *                 </paginationViaCursor>
599
         *             </operation>
600
         *         </operations>
601
         *     </resource>
602
         * </resources>
603
         * ```
604
         *
605
         * </div>
606
         *
607
         * To know more about cursor-based pagination take a look at [this blog post on medium (draft)](https://medium.com/@sroze/74fd1d324723).
608
         */
609
        protected ?array $paginationViaCursor = null,
610
        protected ?array $order = null,
611
        protected ?string $description = null,
612
        protected ?array $normalizationContext = null,
613
        protected ?array $denormalizationContext = null,
614
        protected ?bool $collectDenormalizationErrors = null,
615
        protected string|\Stringable|null $security = null,
616
        protected ?string $securityMessage = null,
617
        protected string|\Stringable|null $securityPostDenormalize = null,
618
        protected ?string $securityPostDenormalizeMessage = null,
619
        protected string|\Stringable|null $securityPostValidation = null,
620
        protected ?string $securityPostValidationMessage = null,
621
        /**
622
         * The `deprecationReason` option deprecates the current operation with a deprecation message.
623
         *
624
         * <div data-code-selector>
625
         *
626
         * ```php
627
         * <?php
628
         * // api/src/Entity/Parchment.php
629
         * use ApiPlatform\Metadata\Get;
630
         *
631
         * #[Get(deprecationReason: 'Create a Book instead')]
632
         * class Parchment
633
         * {
634
         *     // ...
635
         * }
636
         * ```
637
         *
638
         * ```yaml
639
         * # api/config/api_platform/resources.yaml
640
         * resources:
641
         *     App\Entity\Parchment:
642
         *         - operations:
643
         *               ApiPlatform\Metadata\Get:
644
         *                   deprecationReason: 'Create a Book instead'
645
         * ```
646
         *
647
         * ```xml
648
         * <?xml version="1.0" encoding="UTF-8" ?>
649
         * <!-- api/config/api_platform/resources.xml -->
650
         *
651
         * <resources
652
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
653
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
654
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
655
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
656
         *     <resource class="App\Entity\Parchment">
657
         *         <operations>
658
         *             <operation class="ApiPlatform\Metadata\Get" deprecationReason="Create a Book instead" />
659
         *         <operations>
660
         *     </resource>
661
         * </resources>
662
         * ```
663
         *
664
         * </div>
665
         *
666
         * - With JSON-lD / Hydra, [an `owl:deprecated` annotation property](https://www.w3.org/TR/owl2-syntax/#Annotation_Properties) will be added to the appropriate data structure
667
         * - With Swagger / OpenAPI, [a `deprecated` property](https://swagger.io/docs/specification/2-0/paths-and-operations/) will be added
668
         * - With GraphQL, the [`isDeprecated` and `deprecationReason` properties](https://facebook.github.io/graphql/June2018/#sec-Deprecation) will be added to the schema
669
         */
670
        protected ?string $deprecationReason = null,
671
        /**
672
         * The `filters` option configures the filters (declared as services) available on the collection routes for the current resource.
673
         *
674
         * <div data-code-selector>
675
         *
676
         * ```php
677
         * <?php
678
         * // api/src/Entity/Book.php
679
         * use ApiPlatform\Metadata\GetCollection;
680
         *
681
         * #[GetCollection(filters: ['app.filters.book.search'])]
682
         * class Book
683
         * {
684
         *     // ...
685
         * }
686
         * ```
687
         *
688
         * ```yaml
689
         * # api/config/api_platform/resources.yaml
690
         * resources:
691
         *     App\Entity\Book:
692
         *         - operations:
693
         *               ApiPlatform\Metadata\GetCollection:
694
         *                   filters: ['app.filters.book.search']
695
         * ```
696
         *
697
         * ```xml
698
         * <?xml version="1.0" encoding="UTF-8" ?>
699
         * <!-- api/config/api_platform/resources.xml -->
700
         * <resources
701
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
702
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
703
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
704
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
705
         *     <resource class="App\Entity\Book">
706
         *         <operations>
707
         *             <operation class="ApiPlatform\Metadata\GetCollection">
708
         *                 <filters>
709
         *                     <filter>app.filters.book.search</filter>
710
         *                 </filters>
711
         *             </operation>
712
         *         </operations>
713
         *     </resource>
714
         * </resources>
715
         * ```
716
         *
717
         * </div>
718
         */
719
        protected ?array $filters = null,
720
        /**
721
         * The `validationContext` option configure the context of validation for the current Operation.
722
         * You can, for instance, describe the validation groups that will be used :.
723
         *
724
         * ```php
725
         *   #[Put(validationContext: ['groups' => ['Default', 'putValidation']])]
726
         *   #[Post(validationContext: ['groups' => ['Default', 'postValidation']])]
727
         * ```
728
         *
729
         * For more examples, read our guide on [validation](/guides/validation).
730
         */
731
        protected ?array $validationContext = null,
732
        protected $input = null,
733
        protected $output = null,
734
        protected $mercure = null,
735
        /**
736
         * The `messenger` option dispatches the current resource through the Message Bus.
737
         *
738
         * <div data-code-selector>
739
         *
740
         * ```php
741
         * <?php
742
         * // api/src/Entity/Book.php
743
         * use ApiPlatform\Metadata\Post;
744
         *
745
         * #[Post(messenger: true)]
746
         * class Book
747
         * {
748
         *     // ...
749
         * }
750
         * ```
751
         *
752
         * ```yaml
753
         * # api/config/api_platform/resources.yaml
754
         * resources:
755
         *     App\Entity\Book:
756
         *         - operations:
757
         *               ApiPlatform\Metadata\Post:
758
         *                   messenger: true
759
         * ```
760
         *
761
         * ```xml
762
         * <?xml version="1.0" encoding="UTF-8" ?>
763
         * <!-- api/config/api_platform/resources.xml -->
764
         *
765
         * <resources
766
         *         xmlns="https://api-platform.com/schema/metadata/resources-3.0"
767
         *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
768
         *         xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
769
         *         https://api-platform.com/schema/metadata/resources-3.0.xsd">
770
         *     <resource class="App\Entity\Book">
771
         *         <operations>
772
         *             <operation class="ApiPlatform\Metadata\Post" messenger=true />
773
         *         </operations>
774
         *     </resource>
775
         * </resources>
776
         * ```
777
         *
778
         * </div>
779
         *
780
         * Note: when using `messenger=true` on a Doctrine entity, the Doctrine Processor is not called. If you want it
781
         * to be called, you should [decorate a built-in state processor](/docs/guide/hook-a-persistence-layer-with-a-processor)
782
         * and implement your own logic.
783
         *
784
         * Read [how to use Messenger with an Input object](/docs/guide/using-messenger-with-an-input-object).
785
         *
786
         * @var string|bool|null
787
         */
788
        protected $messenger = null,
789
        protected ?bool $elasticsearch = null,
790
        protected ?int $urlGenerationStrategy = null,
791
        protected ?bool $read = null,
792
        protected ?bool $deserialize = null,
793
        protected ?bool $validate = null,
794
        protected ?bool $write = null,
795
        protected ?bool $serialize = null,
796
        protected ?bool $fetchPartial = null,
797
        protected ?bool $forceEager = null,
798
        /**
799
         * The priority helps with the order of operations when looping over a resource's operations.
800
         * It can be usefull when we loop over operations to find a matching IRI, although most of the use cases
801
         * should be covered by the HttpOperation::itemUriTemplate or the ApiProperty::uriTemplate functionalities.
802
         * Sort is ascendant: a lower priority comes first in the list.
803
         */
804
        protected ?int $priority = null,
805
        protected ?string $name = null,
806
        protected $provider = null,
807
        protected $processor = null,
808
        protected ?OptionsInterface $stateOptions = null,
809
        array|Parameters|null $parameters = null,
810
        array|string|null $rules = null,
811
        ?string $policy = null,
812
        array|string|null $middleware = null,
813
        ?bool $queryParameterValidationEnabled = null,
814
        protected ?bool $strictQueryParameterValidation = null,
815
        protected ?bool $hideHydraOperation = null,
816
        protected array $extraProperties = [],
817
    ) {
UNCOV
818
        parent::__construct(
981✔
UNCOV
819
            shortName: $shortName,
981✔
UNCOV
820
            class: $class,
981✔
UNCOV
821
            description: $description,
981✔
UNCOV
822
            urlGenerationStrategy: $urlGenerationStrategy,
981✔
UNCOV
823
            deprecationReason: $deprecationReason,
981✔
UNCOV
824
            normalizationContext: $normalizationContext,
981✔
UNCOV
825
            denormalizationContext: $denormalizationContext,
981✔
UNCOV
826
            collectDenormalizationErrors: $collectDenormalizationErrors,
981✔
UNCOV
827
            validationContext: $validationContext,
981✔
UNCOV
828
            filters: $filters,
981✔
UNCOV
829
            elasticsearch: $elasticsearch,
981✔
UNCOV
830
            mercure: $mercure,
981✔
UNCOV
831
            messenger: $messenger,
981✔
UNCOV
832
            input: $input,
981✔
UNCOV
833
            output: $output,
981✔
UNCOV
834
            order: $order,
981✔
UNCOV
835
            fetchPartial: $fetchPartial,
981✔
UNCOV
836
            forceEager: $forceEager,
981✔
UNCOV
837
            paginationEnabled: $paginationEnabled,
981✔
UNCOV
838
            paginationType: $paginationType,
981✔
UNCOV
839
            paginationItemsPerPage: $paginationItemsPerPage,
981✔
UNCOV
840
            paginationMaximumItemsPerPage: $paginationMaximumItemsPerPage,
981✔
UNCOV
841
            paginationPartial: $paginationPartial,
981✔
UNCOV
842
            paginationClientEnabled: $paginationClientEnabled,
981✔
UNCOV
843
            paginationClientItemsPerPage: $paginationClientItemsPerPage,
981✔
UNCOV
844
            paginationClientPartial: $paginationClientPartial,
981✔
UNCOV
845
            paginationFetchJoinCollection: $paginationFetchJoinCollection,
981✔
UNCOV
846
            paginationUseOutputWalkers: $paginationUseOutputWalkers,
981✔
UNCOV
847
            security: $security,
981✔
UNCOV
848
            securityMessage: $securityMessage,
981✔
UNCOV
849
            securityPostDenormalize: $securityPostDenormalize,
981✔
UNCOV
850
            securityPostDenormalizeMessage: $securityPostDenormalizeMessage,
981✔
UNCOV
851
            securityPostValidation: $securityPostValidation,
981✔
UNCOV
852
            securityPostValidationMessage: $securityPostValidationMessage,
981✔
UNCOV
853
            provider: $provider,
981✔
UNCOV
854
            processor: $processor,
981✔
UNCOV
855
            stateOptions: $stateOptions,
981✔
UNCOV
856
            parameters: $parameters,
981✔
UNCOV
857
            rules: $rules,
981✔
UNCOV
858
            policy: $policy,
981✔
UNCOV
859
            middleware: $middleware,
981✔
UNCOV
860
            queryParameterValidationEnabled: $queryParameterValidationEnabled,
981✔
UNCOV
861
            strictQueryParameterValidation: $strictQueryParameterValidation,
981✔
UNCOV
862
            hideHydraOperation: $hideHydraOperation,
981✔
UNCOV
863
            extraProperties: $extraProperties,
981✔
UNCOV
864
        );
981✔
865
    }
866

867
    public function withOperation($operation)
868
    {
869
        return $this->copyFrom($operation);
×
870
    }
871

872
    public function canRead(): ?bool
873
    {
UNCOV
874
        return $this->read;
927✔
875
    }
876

877
    public function withRead(bool $read = true): static
878
    {
UNCOV
879
        $self = clone $this;
764✔
UNCOV
880
        $self->read = $read;
764✔
881

UNCOV
882
        return $self;
764✔
883
    }
884

885
    public function canDeserialize(): ?bool
886
    {
UNCOV
887
        return $this->deserialize;
926✔
888
    }
889

890
    public function withDeserialize(bool $deserialize = true): static
891
    {
UNCOV
892
        $self = clone $this;
782✔
UNCOV
893
        $self->deserialize = $deserialize;
782✔
894

UNCOV
895
        return $self;
782✔
896
    }
897

898
    public function canValidate(): ?bool
899
    {
UNCOV
900
        return $this->validate;
928✔
901
    }
902

903
    public function withValidate(bool $validate = true): static
904
    {
UNCOV
905
        $self = clone $this;
885✔
UNCOV
906
        $self->validate = $validate;
885✔
907

UNCOV
908
        return $self;
885✔
909
    }
910

911
    public function canWrite(): ?bool
912
    {
UNCOV
913
        return $this->write;
904✔
914
    }
915

916
    public function withWrite(bool $write = true): static
917
    {
UNCOV
918
        $self = clone $this;
863✔
UNCOV
919
        $self->write = $write;
863✔
920

UNCOV
921
        return $self;
863✔
922
    }
923

924
    public function canSerialize(): ?bool
925
    {
UNCOV
926
        return $this->serialize;
898✔
927
    }
928

929
    public function withSerialize(bool $serialize = true): static
930
    {
UNCOV
931
        $self = clone $this;
758✔
UNCOV
932
        $self->serialize = $serialize;
758✔
933

UNCOV
934
        return $self;
758✔
935
    }
936

937
    public function getPriority(): ?int
938
    {
UNCOV
939
        return $this->priority;
96✔
940
    }
941

942
    public function withPriority(int $priority = 0): static
943
    {
UNCOV
944
        $self = clone $this;
75✔
UNCOV
945
        $self->priority = $priority;
75✔
946

UNCOV
947
        return $self;
75✔
948
    }
949

950
    public function getName(): ?string
951
    {
UNCOV
952
        return $this->name;
1,032✔
953
    }
954

955
    public function withName(string $name = ''): static
956
    {
UNCOV
957
        $self = clone $this;
84✔
UNCOV
958
        $self->name = $name;
84✔
959

UNCOV
960
        return $self;
84✔
961
    }
962
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc