Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[FrameworkBundle][DX] Improving the redirect config when using RedirectController#33217
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
6ce11cc to93e69eaComparesrc/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
93e69ea tobea281dComparewouterj commentedAug 17, 2019
👍 What about deprecating the other two methods? (in favor of making them private/protected in Symfony 5.0) |
nicolas-grekas commentedAug 17, 2019
I don't think deprecating is worth the trouble it will put on users. |
linaori commentedAug 17, 2019
From a DX perspective, this would be really amazing if we could make something like this: # config/routes.yamldoc_shortcut:path:/doccontroller:RedirectControllerdefaults:route:'doc_page'legacy_doc:path:/legacy/doccontroller:RedirectControllerdefaults:path:'https://legacy.example.com/doc' Or perhaps: # config/routes.yamldoc_shortcut:path:/docredirect:route:'doc_page'legacy_doc:path:/legacy/docredirect:path:'https://legacy.example.com/doc' |
nicolas-grekas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We should throw also when both settings are defined at the same time.
src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
bea281d todeada37Comparesrc/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
| thrownew \RuntimeException('Ambiguous redirection settings, use the "path" or "route" parameter, not both.'); | ||
| } | ||
| return$this->redirectAction($request,$p['route'],$p['permanent'] ??false,$p['ignoreAttributes'] ??false,$p['keepRequestMethod'] ??false,$p['keepQueryParams'] ??false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
for all the common parameters, you could make them arguments of the controller instead, to let Symfony bind them (with any logic applied by argument resolver, as done for other methods) and take the default values from the method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm not sure if it's worth it just for two common parameters.
src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
2ee8baf to33fd9b0Comparesrc/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
33fd9b0 tocb3cafaComparecb3cafa to0ebb469Compare…en using RedirectController (yceruto)This PR was merged into the 4.4 branch.Discussion----------[FrameworkBundle][DX] Improving the redirect config when using RedirectController| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | -| License | MIT| Doc PR |symfony/symfony-docs#12189follow-up#24637**Before:**```yaml# config/routes.yamldoc_shortcut: path: /doc controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction defaults: route: 'doc_page'legacy_doc: path: /legacy/doc controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction defaults: path: 'https://legacy.example.com/doc'```**After:**```yaml# config/routes.yamldoc_shortcut: path: /doc controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController defaults: route: 'doc_page'legacy_doc: path: /legacy/doc controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController defaults: path: 'https://legacy.example.com/doc'```See more before/after configs (XML, PHP) in doc PRsymfony/symfony-docs#12189Commits-------0ebb469 Improving redirect config when using RedirectController
…ng RedirectController (yceruto)This PR was merged into the 4.4 branch.Discussion----------[FrameworkBundle][DX] Improving redirect config when using RedirectControllerUpdate according tosymfony/symfony#33217Commits-------f59c61f [DX] Improving redirect config
Uh oh!
There was an error while loading.Please reload this page.
follow-up#24637
Before:
After:
See more before/after configs (XML, PHP) in doc PRsymfony/symfony-docs#12189