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

api-platform / core / 15775135891

20 Jun 2025 08:42AM UTC coverage: 22.065% (+0.2%) from 21.876%
15775135891

push

github

soyuka
Merge 4.1

13 of 103 new or added lines in 10 files covered. (12.62%)

868 existing lines in 35 files now uncovered.

11487 of 52060 relevant lines covered (22.06%)

21.72 hits per line

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

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

864
    public function withOperation($operation)
865
    {
UNCOV
866
        return $this->copyFrom($operation);
×
867
    }
868

869
    public function canRead(): ?bool
870
    {
871
        return $this->read;
516✔
872
    }
873

874
    public function withRead(bool $read = true): static
875
    {
876
        $self = clone $this;
452✔
877
        $self->read = $read;
452✔
878

879
        return $self;
452✔
880
    }
881

882
    public function canDeserialize(): ?bool
883
    {
884
        return $this->deserialize;
526✔
885
    }
886

887
    public function withDeserialize(bool $deserialize = true): static
888
    {
889
        $self = clone $this;
485✔
890
        $self->deserialize = $deserialize;
485✔
891

892
        return $self;
485✔
893
    }
894

895
    public function canValidate(): ?bool
896
    {
897
        return $this->validate;
492✔
898
    }
899

900
    public function withValidate(bool $validate = true): static
901
    {
902
        $self = clone $this;
473✔
903
        $self->validate = $validate;
473✔
904

905
        return $self;
473✔
906
    }
907

908
    public function canWrite(): ?bool
909
    {
910
        return $this->write;
496✔
911
    }
912

913
    public function withWrite(bool $write = true): static
914
    {
915
        $self = clone $this;
464✔
916
        $self->write = $write;
464✔
917

918
        return $self;
464✔
919
    }
920

921
    public function canSerialize(): ?bool
922
    {
923
        return $this->serialize;
492✔
924
    }
925

926
    public function withSerialize(bool $serialize = true): static
927
    {
928
        $self = clone $this;
446✔
929
        $self->serialize = $serialize;
446✔
930

931
        return $self;
446✔
932
    }
933

934
    public function getPriority(): ?int
935
    {
936
        return $this->priority;
152✔
937
    }
938

939
    public function withPriority(int $priority = 0): static
940
    {
941
        $self = clone $this;
116✔
942
        $self->priority = $priority;
116✔
943

944
        return $self;
116✔
945
    }
946

947
    public function getName(): ?string
948
    {
949
        return $this->name;
688✔
950
    }
951

952
    public function withName(string $name = ''): static
953
    {
954
        $self = clone $this;
132✔
955
        $self->name = $name;
132✔
956

957
        return $self;
132✔
958
    }
959
}
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