diff --git a/src/Metadata/Extractor/XmlResourceExtractor.php b/src/Metadata/Extractor/XmlResourceExtractor.php index bc382f2553..1a5aea3383 100644 --- a/src/Metadata/Extractor/XmlResourceExtractor.php +++ b/src/Metadata/Extractor/XmlResourceExtractor.php @@ -418,7 +418,6 @@ private function buildOperations(\SimpleXMLElement $resource, array $root): ?arr } $data[] = array_merge($datum, [ - 'collection' => $this->phpize($operation, 'collection', 'bool'), 'class' => (string) $operation['class'], 'method' => $this->phpize($operation, 'method', 'string'), 'read' => $this->phpize($operation, 'read', 'bool'), @@ -426,7 +425,6 @@ private function buildOperations(\SimpleXMLElement $resource, array $root): ?arr 'validate' => $this->phpize($operation, 'validate', 'bool'), 'write' => $this->phpize($operation, 'write', 'bool'), 'serialize' => $this->phpize($operation, 'serialize', 'bool'), - 'queryParameterValidate' => $this->phpize($operation, 'queryParameterValidate', 'bool'), 'priority' => $this->phpize($operation, 'priority', 'integer'), 'routePriority' => $this->phpize($operation, 'routePriority', 'integer'), 'name' => $this->phpize($operation, 'name', 'string'), diff --git a/src/Metadata/Extractor/YamlResourceExtractor.php b/src/Metadata/Extractor/YamlResourceExtractor.php index f73d3a6290..be9e6989b0 100644 --- a/src/Metadata/Extractor/YamlResourceExtractor.php +++ b/src/Metadata/Extractor/YamlResourceExtractor.php @@ -355,6 +355,10 @@ private function buildOperations(array $resource, array $root): ?array throw new InvalidArgumentException(\sprintf('"itemUriTemplate" option is not allowed on a %s operation.', $class)); } + if (isset($operation['queryParameterValidate'])) { + trigger_deprecation('api-platform/core', '5.1', 'The "queryParameterValidate" option has no effect, it is deprecated and will be removed in 6.0. Use "queryParameterValidationEnabled" instead.'); + } + $data[] = array_merge($datum, [ 'read' => $this->phpize($operation, 'read', 'bool'), 'deserialize' => $this->phpize($operation, 'deserialize', 'bool'), diff --git a/src/Metadata/Resource/Factory/ExtractorResourceMetadataCollectionFactory.php b/src/Metadata/Resource/Factory/ExtractorResourceMetadataCollectionFactory.php index fd7abf9d70..f139c60b40 100644 --- a/src/Metadata/Resource/Factory/ExtractorResourceMetadataCollectionFactory.php +++ b/src/Metadata/Resource/Factory/ExtractorResourceMetadataCollectionFactory.php @@ -55,12 +55,6 @@ public function create(string $resourceClass): ResourceMetadataCollection } foreach ($this->buildResources($resources, $resourceClass) as $resource) { - foreach ($this->defaults['attributes'] ?? [] as $key => $value) { - if (method_exists($resource, 'get'.ucfirst($key)) && !$resource->{'get'.ucfirst($key)}()) { - $resource = $resource->{'with'.ucfirst($key)}($value); - } - } - $resourceMetadataCollection[] = $resource; } diff --git a/src/Metadata/Tests/Extractor/XmlExtractorTest.php b/src/Metadata/Tests/Extractor/XmlExtractorTest.php index 1c1e8545de..13daa5949c 100644 --- a/src/Metadata/Tests/Extractor/XmlExtractorTest.php +++ b/src/Metadata/Tests/Extractor/XmlExtractorTest.php @@ -274,10 +274,8 @@ public function testValidXML(): void 'validate' => null, 'write' => null, 'serialize' => null, - 'queryParameterValidate' => null, 'strictQueryParameterValidation' => null, 'hideHydraOperation' => null, - 'collection' => null, 'method' => null, 'priority' => null, 'routePriority' => null, @@ -384,10 +382,8 @@ public function testValidXML(): void 'validate' => null, 'write' => null, 'serialize' => null, - 'queryParameterValidate' => null, 'strictQueryParameterValidation' => null, 'hideHydraOperation' => null, - 'collection' => null, 'method' => null, 'priority' => null, 'routePriority' => null, diff --git a/src/Metadata/Tests/Extractor/YamlExtractorTest.php b/src/Metadata/Tests/Extractor/YamlExtractorTest.php index 62d820e1c8..23df5604f2 100644 --- a/src/Metadata/Tests/Extractor/YamlExtractorTest.php +++ b/src/Metadata/Tests/Extractor/YamlExtractorTest.php @@ -23,6 +23,7 @@ use ApiPlatform\Metadata\Tests\Fixtures\ApiResource\SingleFileConfigDummy; use ApiPlatform\Metadata\Tests\Fixtures\ApiResource\User; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; @@ -645,4 +646,12 @@ public static function getInvalidPaths(): array [__DIR__.'/yaml/invalid/invalid_resources.yaml', '"resources" setting is expected to be null or an array, string given in "'.__DIR__.'/yaml/invalid/invalid_resources.yaml".'], ]; } + + #[IgnoreDeprecations] + public function testQueryParameterValidateIsDeprecated(): void + { + $this->expectUserDeprecationMessage('Since api-platform/core 5.1: The "queryParameterValidate" option has no effect, it is deprecated and will be removed in 6.0. Use "queryParameterValidationEnabled" instead.'); + + (new YamlResourceExtractor([__DIR__.'/yaml/query-parameter-validate.yaml']))->getResources(); + } } diff --git a/src/Metadata/Tests/Extractor/yaml/query-parameter-validate.yaml b/src/Metadata/Tests/Extractor/yaml/query-parameter-validate.yaml new file mode 100644 index 0000000000..7bc482010f --- /dev/null +++ b/src/Metadata/Tests/Extractor/yaml/query-parameter-validate.yaml @@ -0,0 +1,5 @@ +resources: + ApiPlatform\Metadata\Tests\Fixtures\ApiResource\Program: + - operations: + ApiPlatform\Metadata\GetCollection: + queryParameterValidate: false