|
20 | 20 | */
|
21 | 21 | abstract class Metadata
|
22 | 22 | {
|
| 23 | + protected ?Parameters $parameters = null; |
| 24 | + |
23 | 25 | /**
|
24 | 26 | * @param string|null $deprecationReason https://api-platform.com/docs/core/deprecations/#deprecating-resource-classes-operations-and-properties
|
25 | 27 | * @param string|\Stringable|null $security https://api-platform.com/docs/core/security
|
@@ -70,12 +72,18 @@ public function __construct(
|
70 | 72 | protected $provider = null,
|
71 | 73 | protected $processor = null,
|
72 | 74 | protected ?OptionsInterface $stateOptions = null,
|
73 |
| - /** |
| 75 | + /* |
74 | 76 | * @experimental
|
75 | 77 | */
|
76 |
| - protected array|Parameters|null $parameters = [], |
| 78 | + array|Parameters|null $parameters = null, |
| 79 | + protected ?bool $queryParameterValidationEnabled = null, |
77 | 80 | protected array $extraProperties = []
|
78 | 81 | ) {
|
| 82 | + if (\is_array($parameters) && $parameters) { |
| 83 | + $parameters = new Parameters($parameters); |
| 84 | + } |
| 85 | + |
| 86 | + $this->parameters = $parameters; |
79 | 87 | }
|
80 | 88 |
|
81 | 89 | public function getShortName(): ?string
|
@@ -571,18 +579,28 @@ public function withStateOptions(?OptionsInterface $stateOptions): static
|
571 | 579 | return $self;
|
572 | 580 | }
|
573 | 581 |
|
574 |
| - /** |
575 |
| - * @return array<string, Parameter> |
576 |
| - */ |
577 |
| - public function getParameters(): array|Parameters|null |
| 582 | + public function getParameters(): ?Parameters |
578 | 583 | {
|
579 | 584 | return $this->parameters;
|
580 | 585 | }
|
581 | 586 |
|
582 | 587 | public function withParameters(array|Parameters $parameters): static
|
583 | 588 | {
|
584 | 589 | $self = clone $this;
|
585 |
| - $self->parameters = $parameters; |
| 590 | + $self->parameters = \is_array($parameters) ? new Parameters($parameters) : $parameters; |
| 591 | + |
| 592 | + return $self; |
| 593 | + } |
| 594 | + |
| 595 | + public function getQueryParameterValidationEnabled(): ?bool |
| 596 | + { |
| 597 | + return $this->queryParameterValidationEnabled; |
| 598 | + } |
| 599 | + |
| 600 | + public function withQueryParameterValidationEnabled(bool $queryParameterValidationEnabled): static |
| 601 | + { |
| 602 | + $self = clone $this; |
| 603 | + $self->queryParameterValidationEnabled = $queryParameterValidationEnabled; |
586 | 604 |
|
587 | 605 | return $self;
|
588 | 606 | }
|
|
0 commit comments