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 703 forks source link

Do not tag "RequestBodyParamConverter" as final. #2366

Open gusdecool opened 2 years ago

gusdecool commented 2 years ago

Please do not mark class "FOS\RestBundle\Request\RequestBodyParamConverter" as final. This will allow the user to extend the functionality.

There are scenario where we want to extend its functionality like we want to automatically merge the request body to the entity.

example pseudo code

HTTP req

PUT /foo/1

{
    "name": "new name"
}

The existing entity of Foo with id 1 have name: "old name".

Then in controller we will have the parameter already have merge.

public function update(Foo $body) 
{
    print($body->name)
    // output "new name"
    // the value already merged in controller level
}