[Sensiolabs] Add @Template annotation to render() Rector#291
[Sensiolabs] Add @Template annotation to render() Rector#291TomasVotruba merged 47 commits intomasterfrom
Conversation
|
@mssimi Could I ask you for a review? I think we'll have to reimplement |
|
I will test it on my code. |
|
I am unable to run rector of this branch. With dev-master I have no problem.
I actually added some extra commits here #292 , but dont know how to add them to this pull request |
c8421d6 to
aab3c28
Compare
I've just rebased on |
|
@mssimi I've added framework agnostic |
|
It is no good yet:) return $this->redirectToRoute('_forgotten'); // before
return $this->render('AppBundle:User:forgotten.html.twig'); // after// before
return $this->render('@App/User/changePassword.html.twig', array(
'form' => $form->createView()
));
//after
return $this->render('AppBundle:User:passwordChange.html.twig');It should touch only return array statements. For use cases where no other return statement is it seems to work well. |
|
I checked it quickly and still found some problems, but we r getting there:). I will add more commits later today.
Damn most of my ideas require fixing yml and twig:) Edit: @TomasVotruba I added more tests and fixed them in my fork, but after looking more into it I found out, we will have to improve template guesser to match this one. We may have to improve bundle name guessing as well as guessing if Controller is even a bundle, since template annotation works even for non-bundle controller, where template name is generated differently. |
|
@mssimi Could you send PR with failing test cases like before? |
|
@TomasVotruba I tried to re-implement it myself, there is bug in phpdoc regeneration, it generates unneeded space, can't find it. Are you available on hangout to discuss it? |
|
Sure: tomas.vot@gmail.com |
| 'Symfony\Component\Debug\Exception\ContextErrorException': 'ErrorException' | ||
|
|
||
| # http-kernel | ||
| Rector\Rector\Contrib\Symfony\HttpKernel\TemplateAnnotationRector: ~ |
|
@mssimi Could you review please? I've added support for |
|
@TomasVotruba I already refactored one project with that, everything seems fine:) |
|
I've added Thanks for fast cooperation 👍 |
Closes #287
Closes #295
Resources
https://github.com/sensiolabs/SensioFrameworkExtraBundle/blob/master/Templating/TemplateGuesser.php
https://github.com/sensiolabs/SensioFrameworkExtraBundle/blob/master/Tests/Templating/TemplateGuesserTest.php
Docs: https://symfony.com/doc/4.0/bundles/SensioFrameworkExtraBundle/annotations/view.html