I searching for the Symfony way of handling keeping the current GET parameters.
lets say the current url is: http://example.com/cars/?q=Volvo%p=1
Now i have to generate a url based on the current one but modify a parameter: http://example.com/cars/?q=Volvo%p=2
Im searching for the symfony best practice solution for such a case, it can't be the right way simply generating the url by appending all known get parameters by hand.
Doing something like:
$this->generateUrl( 'some_route', array( 'q' => $request->get('q'), 'p' => $request->get('p') ) );
or
$this->generateUrl( 'some_route', array_merge( $request->query->all(), array( 'p' => $request->get('p') + 1 ) ) );
just feels wrong.
There has to be a nice and clean solution for this. Im thinking of something like this:
<!-- path( <route>, <params>, <persist current> ) -->
{{ path( 'some_route', { p: 2 }, true ) }}
The fuelPHP framework for example has the update_query_string method for this.
getparameters are from the pagination. Thats why i have to persist all of them.$request->query->all().