knp-components
knp-components copied to clipboard
[RFC] add a new method to retrieve parameters
Our current implementation is relying on Symfony Request object to retrieve parameters (for sorting and/or filtering). Basically, we simply use $request->query
for an almost-direct access to query string parameters (being $request->query
basically a wrapper around $_GET
).
The main problem of this direct approach is that it's impossible for the developer to add a custom layer, so in the end the variables are exposed to end-users (think, for example, to database field names). See for example https://github.com/KnpLabs/KnpPaginatorBundle/issues/728
My idea is to add an interface to abstract parameter retrieving, and inject it everywhere we inject the Request object, as an optional second argument. An internal implementation of such interface can rely on Request object, being super simple.
In an eventual release, we can deprecate the direct using of Request, making the first argument nullable.
Eventually, in a major release, we'll drop the Request injection and rely only on the new interface.
What do you think?
@polc @julienmiclo @pyatnitsev @ThauEx @javer