Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

[ParamConverters] Object ParamConverter #137

Closed
wants to merge 7 commits into from

Conversation

beberlei
Copy link
Contributor

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.

* 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.
Copy link
Contributor

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.
@beberlei
Copy link
Contributor Author

@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';

Copy link
Member

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).

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@beberlei
Copy link
Contributor Author

I removed the "cookies" and "request" parts. This only makes sense when creating an "empty" object, which only makes sense from query data.

@fabpot fabpot added the for40? label Aug 26, 2017
@astronati
Copy link

@beberlei Any news?

@fabpot
Copy link
Member

fabpot commented Dec 2, 2022

Closing as this repository is not maintained anymore. As of Symfony 6.2, all features have been moved to Symfony core now.
See #783

@fabpot fabpot closed this Dec 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
4 participants