-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Passing objects to Route generator #10395
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
Possibe way might be creating something like ReverseParamConverter annotation to convert arguments to route. |
schmittjoh wrote a library which supports this behaviour |
Thanks a lot! Thus another question: why this is not default functionality of Symfony2 standart or SensioExtraBundle? |
nice idea, wonder if a cookbook would help? if so let's open a ticket in the docu 👶 |
@nick4fake I think this is to complex to implement it into core. |
@Baachi , SensioFrameworkExtra providers one-way converters. I think this is inconsistent. |
Than submit a PR to add this feature 👍 |
I wrote a bundle that does exactly this: https://github.com/iltar/http-bundle. There's no need for additional twig functions, custom routers or custom generators. Please take a look and see if there's anything missing. |
In the past, I was 👍 about this feature ... but now I'm strongly 👎 . Why?
So, not using objects and passing the routes attributes individually is not bad at all to me. I recommend to close this proposal as "won't fix". Thanks! |
Small side note, I try to make things as little effort as possible, therefore things like entities are recognized and simply use the identifier value.
My only concern with this, are batch jobs. You won't often create links with objects in them, so is this really overhead each request? Isn't the path it needs to take, cached as well? |
@iltar I'm still 👎 because this is being lazy once (when writing the route) and paying for it all your life (worse performance when generating URLs in templates). |
@javiereguiluz Writing programs to save human's time by using machine's time... This is the goal of programming, and the goal of Symfony too! This seems not to be a valid argument as we do not generate so much routes. Moreover, we could do that in a way it will be fast to interprete. I particularly liked @ScreamingDev proposal. |
@Zzortell And @ScreamingDev's proposal in the issue you linked causes issues for matching (what would the request attribute look like after matching when the placeholder uses an object access syntax ?) |
Closing here as it looks like we don't want this in core, and it's already doable in a bundle. |
For Symfony2 Router with the help of standart bundle (sensio extra) we can write ParamConverters to convert request param=>object. Is there any standart way to use reversed convertion?
Now we must do something like this:
path('DevBlogBundle_post_show',{'post':post.id})
While a better way would be:
path('DevBlogBundle_post_show',{'post':post})
I've found even example jist:
https://gist.github.com/stevelacey/3226510
Thanks.
The text was updated successfully, but these errors were encountered: