[ParamConverters] Object ParamConverter #137
Conversation
* location for filtering input data is available. | ||
* | ||
* Data is only ever retrieved from the query part of the request, | ||
* use the form framework for transorming POST data into objects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo here
…zable enough. It should be done by the user inside the controller
… for different parts of the requests via the "part" option (as attributes, request, query, cookies). Improve test coverage.
@fabpot could you give your input to this one? I use a copy of this in a project of mine to create criteria objects and pass them to the model layer, its really helpful. I am not sure though if the concept has loop-holes. |
$param = $configuration->getName(); | ||
$options = $configuration->getOptions(); | ||
$part = isset($options['part']) ? $options['part'] : 'query'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The concept of converters is to convert request attributes to objects. I'm not sure that converting other "parts" of the request is something we want to support (cookies is probably out of question I think).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually just use it to access query, something similiar like https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Request/ParamFetcher.php
However domain specific objects instead of the generic object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also for example http://php-and-symfony.matthiasnoback.nl/2012/03/symfony2-creating-a-paramconverter-for-deserializing-request-content/ is also very useful.
I think with named converters this actually makes sense. Say we don't make the object converter part of the iteration, but only allow to use it when explicitly named, in that case developers know what they are doing, when they use it.
I removed the "cookies" and "request" parts. This only makes sense when creating an "empty" object, which only makes sense from query data. |
@beberlei Any news? |
Closing as this repository is not maintained anymore. As of Symfony 6.2, all features have been moved to Symfony core now. |
Allows to convert user input into object graphs (request query). Use-case could be criteria/query objects or other lightweight objects that are not persistent.
See the documentation update for details on how this converter works and the security implications.