-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] TemplateController should accept extra arguments to be sent to the template #35257
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
[FrameworkBundle] TemplateController should accept extra arguments to be sent to the template #35257
Conversation
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.
Hi @Rebolon, thanks for taking care of this. I left some comments to make your "first contribution" happy :)
- The target branch must be
master
for new features (future 5.1),4.4
is already released and must be used for bugfix only. Please, rebase it tomaster
. - A functional test case is required for new features like this one.
Don't hesite to ask any question, thanks again.
@yceruto thx for help. |
Don't worry about it, I can add it at the end, just let me know when the other comments have been fixed. Thanks! |
@yceruto it should be ok right now |
Wow! you were fast ⚡ :) An unit test is enough for me, but can you confirm that this is the new route config for this feature? # config/routes.yaml
acme_privacy:
path: /privacy
controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController
defaults:
template: 'static/privacy.html.twig'
maxAge: 86400
sharedAge: 86400
# optionally you can define some arguments passed to the template
context:
site_name: 'ACME'
theme: 'dark' |
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.
Look good to me after minor comment, thanks!
src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php
Outdated
Show resolved
Hide resolved
@yceruto That's it for the yaml config. |
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.
with minor comment
src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php
Outdated
Show resolved
Hide resolved
(please fix fabbot's report) |
… be sent to the template
Thank you @Rebolon. |
In the official documentation (symfony.com/doc/master/templates.html#rendering-a-template-directly-from-a-route) it says that TemplateController should accept extra arguments. In fact it's not available for instance.
So i added the context argument as an array. Because of deprecation of templating, only the twig instance will apply the context argument.
It will need to be implemented in branch 5.
The following issue has been created in documentation project : symfony/symfony-docs#12897