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

api-platform / core / 6067528200

04 Sep 2023 12:12AM UTC coverage: 36.875% (-21.9%) from 58.794%
6067528200

Pull #5791

github

web-flow
Merge 64157e578 into d09cfc9d2
Pull Request #5791: fix: strip down any sql function name

3096 of 3096 new or added lines in 205 files covered. (100.0%)

9926 of 26918 relevant lines covered (36.87%)

6.5 hits per line

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

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

818
    public function withOperation($operation)
819
    {
820
        return $this->copyFrom($operation);
×
821
    }
822

823
    public function canRead(): ?bool
824
    {
825
        return $this->read;
75✔
826
    }
827

828
    public function withRead(bool $read = true): self
829
    {
830
        $self = clone $this;
3✔
831
        $self->read = $read;
3✔
832

833
        return $self;
3✔
834
    }
835

836
    public function canDeserialize(): ?bool
837
    {
838
        return $this->deserialize;
112✔
839
    }
840

841
    public function withDeserialize(bool $deserialize = true): self
842
    {
843
        $self = clone $this;
45✔
844
        $self->deserialize = $deserialize;
45✔
845

846
        return $self;
45✔
847
    }
848

849
    public function canValidate(): ?bool
850
    {
851
        return $this->validate;
67✔
852
    }
853

854
    public function withValidate(bool $validate = true): self
855
    {
856
        $self = clone $this;
31✔
857
        $self->validate = $validate;
31✔
858

859
        return $self;
31✔
860
    }
861

862
    public function canWrite(): ?bool
863
    {
864
        return $this->write;
76✔
865
    }
866

867
    public function withWrite(bool $write = true): self
868
    {
869
        $self = clone $this;
31✔
870
        $self->write = $write;
31✔
871

872
        return $self;
31✔
873
    }
874

875
    public function canSerialize(): ?bool
876
    {
877
        return $this->serialize;
75✔
878
    }
879

880
    public function withSerialize(bool $serialize = true): self
881
    {
882
        $self = clone $this;
×
883
        $self->serialize = $serialize;
×
884

885
        return $self;
×
886
    }
887

888
    public function getPriority(): ?int
889
    {
890
        return $this->priority;
129✔
891
    }
892

893
    public function withPriority(int $priority = 0): self
894
    {
895
        $self = clone $this;
42✔
896
        $self->priority = $priority;
42✔
897

898
        return $self;
42✔
899
    }
900

901
    public function getName(): ?string
902
    {
903
        return $this->name;
627✔
904
    }
905

906
    public function withName(string $name = ''): self
907
    {
908
        $self = clone $this;
126✔
909
        $self->name = $name;
126✔
910

911
        return $self;
126✔
912
    }
913
}
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

© 2026 Coveralls, Inc