Skip to content

Commit

Permalink
Merge pull request #4845 from nawel-les-tilleuls/feat/upgrade-filters
Browse files Browse the repository at this point in the history
Migrate ApiFilter to new format
  • Loading branch information
vincentchalamon authored Jul 25, 2022
2 parents 1470b1f + 77bd78d commit 5f4ceb6
Show file tree
Hide file tree
Showing 8 changed files with 417 additions and 6 deletions.
100 changes: 98 additions & 2 deletions features/main/subresource.feature
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Feature: Subresource support
"hydra:totalItems": 2,
"hydra:search": {
"@type": "hydra:IriTemplate",
"hydra:template": "/dummies/1/related_dummies{?relatedToDummyFriend.dummyFriend,relatedToDummyFriend.dummyFriend[],name,age,age[]}",
"hydra:template": "/dummies/1/related_dummies{?relatedToDummyFriend.dummyFriend,relatedToDummyFriend.dummyFriend[],name,age,age[],id,id[],symfony,symfony[],dummyDate[before],dummyDate[strictly_before],dummyDate[after],dummyDate[strictly_after]}",
"hydra:variableRepresentation": "BasicRepresentation",
"hydra:mapping": [
{
Expand Down Expand Up @@ -140,6 +140,54 @@ Feature: Subresource support
"variable": "age[]",
"property": "age",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "id",
"property": "id",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "id[]",
"property": "id",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "symfony",
"property": "symfony",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "symfony[]",
"property": "symfony",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "dummyDate[before]",
"property": "dummyDate",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "dummyDate[strictly_before]",
"property": "dummyDate",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "dummyDate[after]",
"property": "dummyDate",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "dummyDate[strictly_after]",
"property": "dummyDate",
"required": false
}
]
}
Expand Down Expand Up @@ -185,7 +233,7 @@ Feature: Subresource support
},
"hydra:search": {
"@type": "hydra:IriTemplate",
"hydra:template": "/dummies/1/related_dummies{?relatedToDummyFriend.dummyFriend,relatedToDummyFriend.dummyFriend[],name,age,age[]}",
"hydra:template": "/dummies/1/related_dummies{?relatedToDummyFriend.dummyFriend,relatedToDummyFriend.dummyFriend[],name,age,age[],id,id[],symfony,symfony[],dummyDate[before],dummyDate[strictly_before],dummyDate[after],dummyDate[strictly_after]}",
"hydra:variableRepresentation": "BasicRepresentation",
"hydra:mapping": [
{
Expand Down Expand Up @@ -217,6 +265,54 @@ Feature: Subresource support
"variable": "age[]",
"property": "age",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "id",
"property": "id",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "id[]",
"property": "id",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "symfony",
"property": "symfony",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "symfony[]",
"property": "symfony",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "dummyDate[before]",
"property": "dummyDate",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "dummyDate[strictly_before]",
"property": "dummyDate",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "dummyDate[after]",
"property": "dummyDate",
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "dummyDate[strictly_after]",
"property": "dummyDate",
"required": false
}
]
}
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ parameters:
- src/Core/Upgrade/SubresourceTransformer.php
- src/Core/Upgrade/UpgradeApiResourceVisitor.php
- src/Core/Upgrade/UpgradeApiSubresourceVisitor.php
- src/Core/Upgrade/UpgradeApiFilterVisitor.php
- src/Core/Util/AttributesExtractor.php
- src/Core/Util/ErrorFormatGuesser.php
- src/Core/Util/Inflector.php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use ApiPlatform\Core\Operation\Factory\SubresourceOperationFactoryInterface;
use ApiPlatform\Core\Upgrade\ColorConsoleDiffFormatter;
use ApiPlatform\Core\Upgrade\SubresourceTransformer;
use ApiPlatform\Core\Upgrade\UpgradeApiFilterVisitor;
use ApiPlatform\Core\Upgrade\UpgradeApiResourceVisitor;
use ApiPlatform\Core\Upgrade\UpgradeApiSubresourceVisitor;
use ApiPlatform\Exception\ResourceClassNotFoundException;
Expand Down Expand Up @@ -107,6 +108,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$traverser = new NodeTraverser();
[$attribute, $isAnnotation] = $this->readApiResource($resourceClass);

$traverser->addVisitor(new UpgradeApiFilterVisitor($this->reader, $resourceClass));

if (!$attribute) {
continue;
}
Expand Down
Loading

0 comments on commit 5f4ceb6

Please sign in to comment.