Skip to content

Commit b2f1a5a

Browse files
authored
feat(metadata): throwOnNotFound option (#6027)
1 parent 34e46af commit b2f1a5a

23 files changed

Lines changed: 232 additions & 9 deletions

src/Metadata/ApiResource.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,7 @@ public function __construct(
978978
protected ?bool $strictQueryParameterValidation = null,
979979
protected ?bool $hideHydraOperation = null,
980980
protected ?bool $jsonStream = null,
981+
protected ?bool $throwOnNotFound = null,
981982
protected array $extraProperties = [],
982983
?bool $map = null,
983984
protected ?array $mcp = null,
@@ -1026,6 +1027,7 @@ class: $class,
10261027
strictQueryParameterValidation: $strictQueryParameterValidation,
10271028
hideHydraOperation: $hideHydraOperation,
10281029
jsonStream: $jsonStream,
1030+
throwOnNotFound: $throwOnNotFound,
10291031
extraProperties: $extraProperties,
10301032
map: $map,
10311033
);

src/Metadata/Delete.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public function __construct(
102102
?bool $strictQueryParameterValidation = null,
103103
protected ?bool $hideHydraOperation = null,
104104
?bool $jsonStream = null,
105+
?bool $throwOnNotFound = null,
105106
array $extraProperties = [],
106107
?bool $map = null,
107108
) {
@@ -187,6 +188,7 @@ class: $class,
187188
parameters: $parameters,
188189
strictQueryParameterValidation: $strictQueryParameterValidation,
189190
hideHydraOperation: $hideHydraOperation,
191+
throwOnNotFound: $throwOnNotFound,
190192
stateOptions: $stateOptions,
191193
map: $map
192194
);

src/Metadata/Extractor/XmlResourceExtractor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ private function buildBase(\SimpleXMLElement $resource): array
149149
'write' => $this->phpize($resource, 'write', 'bool'),
150150
'jsonStream' => $this->phpize($resource, 'jsonStream', 'bool'),
151151
'map' => $this->phpize($resource, 'map', 'bool'),
152+
'throwOnNotFound' => $this->phpize($resource, 'throwOnNotFound', 'bool'),
152153
];
153154
}
154155

src/Metadata/Extractor/YamlResourceExtractor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ private function buildBase(array $resource): array
176176
'write' => $this->phpize($resource, 'write', 'bool'),
177177
'jsonStream' => $this->phpize($resource, 'jsonStream', 'bool'),
178178
'map' => $this->phpize($resource, 'map', 'bool'),
179+
'throwOnNotFound' => $this->phpize($resource, 'throwOnNotFound', 'bool'),
179180
];
180181
}
181182

src/Metadata/Extractor/schema/resources.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@
526526
<xsd:attribute type="xsd:boolean" name="collectDenormalizationErrors"/>
527527
<xsd:attribute type="xsd:boolean" name="jsonStream"/>
528528
<xsd:attribute type="xsd:boolean" name="map"/>
529+
<xsd:attribute type="xsd:boolean" name="throwOnNotFound"/>
529530
</xsd:attributeGroup>
530531

531532
<xsd:attributeGroup name="extendedBase">

src/Metadata/Get.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public function __construct(
102102
?bool $strictQueryParameterValidation = null,
103103
protected ?bool $hideHydraOperation = null,
104104
?bool $jsonStream = null,
105+
?bool $throwOnNotFound = null,
105106
array $extraProperties = [],
106107
?bool $map = null,
107108
) {
@@ -186,6 +187,7 @@ class: $class,
186187
strictQueryParameterValidation: $strictQueryParameterValidation,
187188
hideHydraOperation: $hideHydraOperation,
188189
jsonStream: $jsonStream,
190+
throwOnNotFound: $throwOnNotFound,
189191
extraProperties: $extraProperties,
190192
map: $map
191193
);

src/Metadata/GetCollection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public function __construct(
103103
protected ?bool $hideHydraOperation = null,
104104
?bool $jsonStream = null,
105105
array $extraProperties = [],
106+
?bool $throwOnNotFound = null,
106107
private ?string $itemUriTemplate = null,
107108
?bool $map = null,
108109
) {
@@ -181,6 +182,7 @@ class: $class,
181182
processor: $processor,
182183
parameters: $parameters,
183184
jsonStream: $jsonStream,
185+
throwOnNotFound: $throwOnNotFound,
184186
extraProperties: $extraProperties,
185187
rules: $rules,
186188
policy: $policy,

src/Metadata/HttpOperation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public function __construct(
222222
array|string|null $middleware = null,
223223
?bool $queryParameterValidationEnabled = null,
224224
?bool $jsonStream = null,
225+
?bool $throwOnNotFound = null,
225226
array $extraProperties = [],
226227
?bool $map = null,
227228
) {
@@ -283,6 +284,7 @@ class: $class,
283284
strictQueryParameterValidation: $strictQueryParameterValidation,
284285
hideHydraOperation: $hideHydraOperation,
285286
jsonStream: $jsonStream,
287+
throwOnNotFound: $throwOnNotFound,
286288
extraProperties: $extraProperties,
287289
map: $map
288290
);

src/Metadata/Metadata.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function __construct(
8282
protected ?bool $hideHydraOperation = null,
8383
protected ?bool $jsonStream = null,
8484
protected ?bool $map = null,
85+
protected ?bool $throwOnNotFound = null,
8586
protected array $extraProperties = [],
8687
) {
8788
if (\is_array($parameters) && $parameters) {
@@ -655,6 +656,19 @@ public function withMiddleware(string|array $middleware): static
655656
return $self;
656657
}
657658

659+
public function getThrowOnNotFound(): ?bool
660+
{
661+
return $this->throwOnNotFound;
662+
}
663+
664+
public function withThrowOnNotFound(bool $throwOnNotFound): static
665+
{
666+
$self = clone $this;
667+
$self->throwOnNotFound = $throwOnNotFound;
668+
669+
return $self;
670+
}
671+
658672
public function getExtraProperties(): ?array
659673
{
660674
return $this->extraProperties;

src/Metadata/Operation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ public function __construct(
814814
protected ?bool $strictQueryParameterValidation = null,
815815
protected ?bool $hideHydraOperation = null,
816816
protected ?bool $jsonStream = null,
817+
protected ?bool $throwOnNotFound = null,
817818
protected array $extraProperties = [],
818819
?bool $map = null,
819820
) {
@@ -862,6 +863,7 @@ class: $class,
862863
strictQueryParameterValidation: $strictQueryParameterValidation,
863864
hideHydraOperation: $hideHydraOperation,
864865
jsonStream: $jsonStream,
866+
throwOnNotFound: $throwOnNotFound,
865867
extraProperties: $extraProperties,
866868
map: $map
867869
);

0 commit comments

Comments
 (0)