FriendsOfSymfony / FOSRestBundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony
http://symfony.com/doc/master/bundles/FOSRestBundle/index.html
MIT License
2.79k stars 708 forks source link

[WIP] Create a controller argument resolver to replace the param converter #2398

Open mbabker opened 7 months ago

mbabker commented 7 months ago

This is an attempt to get the ball rolling at deprecating the param converter integration in favor of the framework's native argument resolvers. It's untested, it does not have 100% feature parity with the existing implementation (some of that being by design since the two systems are different), and it's kind of a Frankenbeast trying to deal with Symfony 5.4 support, but here we are.

Note, this will only support PHP 8. Considering the Sensio bundle works fine on Symfony 5.4 and Symfony 6 requires PHP 8, as well as argument resolvers having only ever supported PHP 8 attributes (#[CurrentUser] exists in Symfony 5.4 but has no @Annotation declaration), I personally don't see that as an issue.

The attribute and resolver design try to take inspiration from the framework's #[MapRequestPayload] attribute and RequestPayloadValueResolver while only re-implementing the functionality in the existing RequestBodyParamConverter. So the validator integration is still opt-in (whereas in the framework if the validator's injected it is always used), and this bundle's serializer bridge continues to be used.

Things that have changed in the workflow:

Things that still need to be done if this is usable: