merged branch fabpot/hinclude-fix (PR #7116)
This PR was merged into the 2.2 branch.
Commits
-------
3933912
fixed HInclude renderer (closes #7113)
Discussion
----------
fixed HInclude renderer (closes #7113)
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #7113
| License | MIT
| Doc PR | n/a
---------------------------------------------------------------------------
by stof at 2013-02-19T08:36:20Z
👍
This commit is contained in:
commit
dde77ee99a
@ -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