-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DX][FrameworkBundle] Simpler route configuration for templates and redirections #24640
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
👍 |
1 similar comment
👍 |
These would require making the routing component depend on FrameworkBundle (these special controllers are part of the bundle, but route definitions are handled in the component) |
@stof there's no need for that. If you have router + frameworkbundle, you can use this feature. If you don't have frameworkbundle and try to use this feature, you'll see an exception. We already do that for lots of Symfony features. |
This is indeed a great simplification. Huge 👍 |
Proposed a PR for the redirection in #25145 |
I'm really not sure about that part. And I'm not sure we do it for any Symfony features. High-level can adapt to varying low level stuffs. But having a low level stuff (Routing) know about a high level one (FrameworkBundle) looks strange to me. |
I would do it differently: instead of setting a controller, the |
Yep, I agree it would be a better option. Let's discuss the implementation details within the PR :) |
Or maybe can we just pass unknown keys (or even all keys) as request's attributes. It solves all issues and provides a great extension point for new usages. |
But this increases the risk of a bad DX because of typos and things like that... I'd prefer having a proper validation around it tbh |
…le template and redirect controllers (HeahDude) This PR was merged into the 5.1-dev branch. Discussion ---------- [FrameworkBundle][Routing] added Configurators to handle template and redirect controllers | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | let's see | Fixed tickets | partially #24640, #25145 | License | MIT | Doc PR | symfony/symfony-docs#11120 While working on symfony/symfony-docs#11085, I felt bad about the long notations required for simple [redirects](https://symfony.com/doc/current/routing/redirect_in_config.html) and [templates rendering](https://symfony.com/doc/current/templating/render_without_controller.html) template actions, but I love and use those features since always. Then I gave it a try yesterday night and now I realised I missed #24640 and that #25145 has been closed x). So here we go, here's my WIP. WDYT of this implementation? ping @javiereguiluz? I'm going to open the PR in the docs so we can discuss the DX changes there too, and keep focus on the code here. Cheers! EDIT ---- This PR now only update PHP-DSL configurators. ______________ TODO: - [x] gather reviews - ~[x] fix xml schema~ - [x] add some tests - ~[ ] handle xsd auto discovery~ - [x] rebase on top of #30507 - [x] ~add shortcuts for #30514~ Commits ------- de74794 [FrameworkBundle][Routing] added Configurators to handle template and redirect controllers
Thank you for this suggestion. |
On my side, I think #35653 had the correct approach. |
Context
In #23227 we made this change:
In #24637 we improved a bit the routes that render a template directly, but I don't think that's enough.
Proposal
Let's finish #23227 by adding shortcuts for templates and redirections:
Templates
Redirections
If the value of
redirect_to
starts with/
or//
orhttp://
orhttps://
, it's considered a URL redirect. Otherwise, it's a route redirect:The text was updated successfully, but these errors were encountered: