Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/Metadata/Extractor/XmlResourceExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,13 @@ 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'),
'deserialize' => $this->phpize($operation, 'deserialize', 'bool'),
'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'),
Expand Down
4 changes: 4 additions & 0 deletions src/Metadata/Extractor/YamlResourceExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 0 additions & 4 deletions src/Metadata/Tests/Extractor/XmlExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions src/Metadata/Tests/Extractor/YamlExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resources:
ApiPlatform\Metadata\Tests\Fixtures\ApiResource\Program:
- operations:
ApiPlatform\Metadata\GetCollection:
queryParameterValidate: false
Loading