Simple redirection in Symfony2 by changing a non-route request string parameter

It should be simple, and I have searched all over Google, but I continue to come up with related routes.

I just want to redirect to one page and change one of the query string parameters (either clear or install).

I do not see how to do this.

An option might be to manually create the URL and use this, I think, but this is not a good method:

$this->router->generate("http://domain.com?a=1")
+5
source share
2 answers

I hope I understand what you intend to do ... In your controller (?) Use

$this->generateUrl(
    $request->attributes->get('_route'),
    array_merge(
        $request->query->all(),
        array('param' => 'val') // change the param
    )
);

to generate the url.

+7
source

? , , ? , . ( ).

:

public function indexAction()
{
    // ...
    return $this->redirect($this->generateUrl($request->attributes->get('_route'), array('paramName' => $paramValue)));
}

, : http://symfony.com/doc/current/book/internals.html#handling-requests

0

All Articles