Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[TwigBridge] Expose current route inAppVariable#47535
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
2e9a971 to43dd724CompareUh oh!
There was an error while loading.Please reload this page.
43dd724 to1cb7c64CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
1cb7c64 to67aae53CompareThank you@HeahDude. |
…teParameters methods (Kocal)This PR was merged into the 6.2 branch.Discussion----------[TwigBridge] Fix casing of getCurrentRoute/getCurrentRouteParameters methods| Q | A| ------------- | ---| Branch? | 6.2| Bug fix? | yes| New feature? | no <!-- please update src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->| License | MIT| Doc PR | -Following of#47535, those two methods were named like this in order to get `app.current_route` and `app.current_route_parameters`, however PHPStorm autocomplete for `app.current_Route` and `app.current_Route_Parameters`.I'm not sure if this is a PHPStorm-only issue or not.**Before:****After:**<img width="604" alt="image" src="https://user-images.githubusercontent.com/2103975/205177787-b3e55d95-4a0f-40ea-8b65-a0b3ddc447f0.png">Commits-------67588b3 [TwigBridge] Fix casing of currentRoute/currentRouteParameters methods
Uh oh!
There was an error while loading.Please reload this page.
In my experience, a Symfony web project using Twig always comes with templates using
app.request.attributes.get('_route'), a most common exemple:(An idea of how much it can be used at:https://github.com/search?q=app.request.attributes.get%28%27_route%27%29&type=code).
The current way is somehow complex and not easy to discover, also trying to search the
currentkeyword in Routing and Twig sections of the docs does not show the expected exemple.However searching for
_routemay lead tohttps://symfony.com/doc/current/routing.html#getting-the-route-name-and-parameters.I propose with this PR to introduce two small helpers in the global
AppVariable:{%setcurrent_route=app.current_route %}{%setcurrent_params=app.current_route_parameters %}