10000 [2.2] [Routing] Re-generating the current URL · Issue #4849 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Closed
Seldaek opened this issue Jul 11, 2012 · 10 comments
Closed

[2.2] [Routing] Re-generating the current URL #4849

Seldaek opened this issue Jul 11, 2012 · 10 comments
Labels

Comments

@Seldaek
Copy link
Member
Seldaek commented Jul 11, 2012

(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 hackish null behavior.
@Tobion
Copy link
Contributor
Tobion commented Jul 11, 2012

Basically what I proposed in #3965

@Seldaek
Copy link
Member Author
Seldaek commented Jul 11, 2012

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.

@Tobion
Copy link
Contributor
Tobion commented Jul 11, 2012

I don't understand what you propose that my PR could not accomplish? Seeing your path(null,...) example is excatly what my subpath('', ...) does. Please give another example.

@Seldaek
Copy link
Member Author
Seldaek commented Jul 11, 2012

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.

@Tobion
Copy link
Contributor
Tobion commented Jul 11, 2012

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 view route with some params and now you want to generate the edit route with the same params).

@Seldaek
Copy link
Member Author
Seldaek commented Jul 11, 2012

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.

@Tobion
Copy link
Contributor
Tobion commented Jul 11, 2012

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 {{ subpath({foo:"bar"}) }} which is then equal to your self.

@marcojanssen
Copy link

@Tobion @Seldaek This issue is almost 3 years old, is this still relevant?

@Seldaek
Copy link
Member Author
Seldaek commented Jul 13, 2015 via email

@marcojanssen
Copy link

@Tobion @Seldaek So we can close it right?

@fabpot fabpot closed this as completed Jul 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants
0