[FrameworkBundle] Deprecate renderView() in favor of renderTemplate()#36184
[FrameworkBundle] Deprecate renderView() in favor of renderTemplate()#36184fabpot merged 1 commit intosymfony:masterfrom
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.
Do we consider this is worth the migration cost?
| */ | ||
| 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.
trigger_deprecation() + missing annotation
There was a problem hiding this comment.
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. |
| 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/f 8000 ramework-bundle 5.1: "renderView()" method is deprecated. Use "renderTemplate()" instead.', E_USER_DEPRECATED); |
There was a problem hiding this comment.
well actually that's broken, you'll figure out :)
There was a problem hiding this comment.
(don't miss the annotation also)
| */ | ||
| 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.
The "renderView()" method [...]?
| */ | ||
| 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.
that's not the signature of the function, and the annotation is missing
There was a problem hiding this comment.
(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 |