-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Deprecate renderView() in favor of renderTemplate() #36184
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
Conversation
Q | A |
---|---|
Branch? | master |
Bug fix? | no |
New feature? | no |
Deprecations? | yes |
Tickets | - |
License | MIT |
Doc PR | - |
src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php
Outdated
Show resolved
Hide resolved
@nicolas-grekas I reverted the milestone. We cannot introduce a new deprecation in 5.0.x |
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.
Do we consider this is worth the migration cost?
@@ -241,20 +241,30 @@ protected function denyAccessUnlessGranted($attributes, $subject = null, string | |||
* Returns a rendered view. | |||
*/ | |||
protected function renderView(string $view, array $parameters = []): string | |||
{ | |||
@trigger_error('Since symfony/framework-bundle 5.1: "renderView()" method is deprecated. Use "renderTemplate()" instead.', E_USER_DEPRECATED); |
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.
trigger_deprecation() + missing annotation
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.
oh also: changelog+upgrade files should be updated
About the migration cost ... I would never change the |
Seems about right. Not exactly a factor of 100 but here some numbers from my biggest Symfony 4.4 work project:
|
Another point. MVC division: Model, view, controller. Most programmers associate with such an approach that the controller generates a view, not a template. |
@@ -242,7 +242,7 @@ protected function denyAccessUnlessGranted($attributes, $subject = null, string | |||
*/ | |||
protected function renderView(string $view, array $parameters = []): string | |||
{ | |||
@trigger_error('Since symfony/framework-bundle 5.1: "renderView()" method is deprecated. Use "renderTemplate()" instead.', E_USER_DEPRECATED); | |||
@trigger_deprecation('Since symfony/framework-bundle 5.1: "renderView()" method is deprecated. Use "renderTemplate()" instead.', E_USER_DEPRECATED); |
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.
s/@//
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.
well actually that's broken, you'll figure out :)
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.
(don't miss the annotation also)
@@ -241,20 +241,30 @@ protected function denyAccessUnlessGranted($attributes, $subject = null, string | |||
* Returns a rendered view. | |||
*/ | |||
protected function renderView(string $view, array $parameters = []): string | |||
{ | |||
trigger_deprecation('Since symfony/framework-bundle 5.1: "renderView()" method is deprecated. Use "renderTemplate()" instead.', E_USER_DEPRECATED); |
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.
The "renderView()" method [...]?
@@ -241,20 +241,30 @@ protected function denyAccessUnlessGranted($attributes, $subject = null, string | |||
* Returns a rendered view. | |||
*/ | |||
protected function renderView(string $view, array $parameters = []): string | |||
{ | |||
trigger_deprecation('Since symfony/framework-bundle 5.1: "renderView()" method is deprecated. Use "renderTemplate()" instead.', E_USER_DEPRECATED); |
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.
that's not the signature of the function, and the annotation is missing
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.
(just to confirm this needs a few more hops)
src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php
Outdated
Show resolved
Hide resolved
Thank you @javiereguiluz. |
Actually, that's a hard BC break. What if one already has a |
Sure, let's revert if it needs more thoughts. |
@fabpot I hadn't thought about that ... but then, we'll never be able to add any new method to AbstractController ... because someone may have already defined it 🤔 |
@javiereguiluz That's correct :( |
reverted |
A possible solution would be to deprecate defining custom public function renderView(...)
{
if (method_exists($this, 'renderTemplate')) {
@trigger_deprecation('
You define a custom renderTemplate() method in your controllers,
but Symfony will add that method in Symfony 6.0, so you should
rename your method.
');
}
// ...
} But then we could only deprecate |