Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
@QueryParam default value from the PHP code directly #416
Like Symfony. see http://symfony.com/blog/new-in-symfony-2-2-small-things-matter
The problem is a bit deeper I think. If I have something like:
/** * @Rest\QueryParam(name="page", requirements="\d+", default="1", description="Page of the overview") * @Rest\QueryParam(name="limit", requirements="\d+", default="25", description="Limit per page") */ public function indexAction($page = 1, $limit = 25)
and set param_fetcher_listener to force I'm getting an exception from:
If I remove the defaults from the method-signature, everything is working fine. So we have a conflct between ParamFetcher from FOSRest and ParamConverter from SensioExtraBundle.
I would be happy to provide a patch, but I'm unsure what`s the intended behavior would be. The simplest (and imho propably best) solution would be, to simple remove the Exception from ParamFetcherListener and document the behaviour, that if both Listeners are used, the ParamConverter takes precedence.
As I thought a bit more about this topic, it became clear, that the problem is more or less conceptional. The root-problem is that the force-option copies content from one "context" (in symfony terms query- to request) to another and there is no defined solution to handle possible conflicts.
If I think about the expected behavior, I would say that defaults of QueryParamFetcher should take precedence because it is the place where I define the query-parameter I am actually sending. This would also play nice with the term "force" in the ParamFetcher-config.
So imho there are two possible solutions:
Either way, there should be a defined and documented way to resolve this (or not) :)