[FrameworkBundle] Fix bad interface hint in AbstractController

This commit is contained in:
Nicolas Grekas 2017-10-05 10:44:57 +02:00
parent 0a963d2b4e
commit 5d29dd0d28
2 changed files with 6 additions and 6 deletions

View File

@ -231,10 +231,10 @@ trait ControllerTrait
protected function render($view, array $parameters = array(), Response $response = null) protected function render($view, array $parameters = array(), Response $response = null)
{ {
if ($this->container->has('templating')) { if ($this->container->has('templating')) {
return $this->container->get('templating')->renderResponse($view, $parameters, $response); $content = $this->container->get('templating')->render($view, $parameters);
} } elseif ($this->container->has('twig')) {
$content = $this->container->get('twig')->render($view, $parameters);
if (!$this->container->has('twig')) { } else {
throw new \LogicException('You can not use the "render" method if the Templating Component or the Twig Bundle are not available.'); throw new \LogicException('You can not use the "render" method if the Templating Component or the Twig Bundle are not available.');
} }
@ -242,7 +242,7 @@ trait ControllerTrait
$response = new Response(); $response = new Response();
} }
$response->setContent($this->container->get('twig')->render($view, $parameters)); $response->setContent($content);
return $response; return $response;
} }

View File

@ -451,7 +451,7 @@ abstract class ControllerTraitTest extends TestCase
public function testRenderTemplating() public function testRenderTemplating()
{ {
$templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock();
$templating->expects($this->once())->method('renderResponse')->willReturn(new Response('bar')); $templating->expects($this->once())->method('render')->willReturn('bar');
$container = new Container(); $container = new Container();
$container->set('templating', $templating); $container->set('templating', $templating);