fixed HInclude renderer (closes #7113)
This commit is contained in:
parent
ec885bf5f4
commit
39339121d6
@ -40,7 +40,9 @@ class ContainerAwareHIncludeFragmentRenderer extends HIncludeFragmentRenderer
|
|||||||
*/
|
*/
|
||||||
public function render($uri, Request $request, array $options = array())
|
public function render($uri, Request $request, array $options = array())
|
||||||
{
|
{
|
||||||
if (!$this->templating) {
|
// setting the templating cannot be done in the constructor
|
||||||
|
// as it would lead to an infinite recursion in the service container
|
||||||
|
if (!$this->hasTemplating()) {
|
||||||
$this->setTemplating($this->container->get('templating'));
|
$this->setTemplating($this->container->get('templating'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Bundle\FrameworkBundle\Tests\Fragment;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Fragment\ContainerAwareHIncludeFragmentRenderer;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
class ContainerAwareHIncludeFragmentRendererTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testRender()
|
||||||
|
{
|
||||||
|
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||||
|
$container->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->will($this->returnValue($this->getMock('\Twig_Environment')))
|
||||||
|
;
|
||||||
|
$renderer = new ContainerAwareHIncludeFragmentRenderer($container);
|
||||||
|
$renderer->render('/', Request::create('/'));
|
||||||
|
}
|
||||||
|
}
|
@ -56,6 +56,16 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
|||||||
$this->templating = $templating;
|
$this->templating = $templating;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a templating engine has been set.
|
||||||
|
*
|
||||||
|
* @return Boolean true if the templating engine has been set, false otherwise
|
||||||
|
*/
|
||||||
|
public function hasTemplating()
|
||||||
|
{
|
||||||
|
return null !== $this->templating;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user