Skip to content

Commit

Permalink
fixed HInclude renderer (closes #7113)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Feb 19, 2013
1 parent ec885bf commit 3933912
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
Expand Up @@ -40,7 +40,9 @@ public function __construct(ContainerInterface $container, UriSigner $signer = n
*/
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'));
}

Expand Down
@@ -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('/'));
}
}
Expand Up @@ -56,6 +56,16 @@ public function setTemplating($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}
*
Expand Down

0 comments on commit 3933912

Please sign in to comment.