-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.2] [Routing] Re-generating the current URL #4849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Basically what I proposed in #3965 |
Not it's not quite the same, this just generates the current requests' link through the routing, which allows you to change a few variables. It does not help you to generate another url that is a sub-path of the current one, it makes no assumption about URL structure whatsoever. |
I don't understand what you propose that my PR could not accomplish? Seeing your |
Maybe this use case is covered by your code, but I think your code does way more, and it's arguable whether that's a good idea or not. |
Huh? The only thing that my code does more is that you can not only generate the same route with new params but also a different route with these params (e.g. you have a |
Well fair enough, I thought it included all of #3958 as well. Anyway I guess this is covered by your PR, so if that gets merged I'm happy, if it doesn't then the issue is still valid as a more simplistic approach. |
No, it's unrelated to relative paths (it should just generate relative paths by default IMO). Btw, I can also allow to omit the empty/null route name with |
I guess not.. At least I haven't had such need that I can remember because
it's easy enough to get the current url from Request.
|
(Derived from #2951)
Generating the current URL is sometimes useful, one common example is to create links to the same page with a different locale, but there are other use cases like multi-parameterized routes where you want to change one while keeping the rest intact.
I would like to propose the following alternatives (in twig helpers, but the same should be added to the UrlGenerator obviously):
{{ path(null, {foo:"bar"}) }}
:null
would generate the current route, and automatically merge the second arg with the current requests's_route_params
.{{ self({foo: "bar"}) }}
: a new helper for this behavior instead of hackishnull
behavior.The text was updated successfully, but these errors were encountered: