Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dde77ee

Browse files
committed
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 :+1:
2 parents aa428fe + 3933912 commit dde77ee

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ public function __construct(ContainerInterface $container, UriSigner $signer = n
4040
*/
4141
public function render($uri, Request $request, array $options = array())
4242
{
43-
if (!$this->templating) {
43+
// setting the templating cannot be done in the constructor
44+
// as it would lead to an infinite recursion in the service container
45+
if (!$this->hasTemplating()) {
4446
$this->setTemplating($this->container->get('templating'));
4547
}
4648

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\Fragment;
13+
14+
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
15+
use Symfony\Bundle\FrameworkBundle\Fragment\ContainerAwareHIncludeFragmentRenderer;
16+
use Symfony\Component\HttpFoundation\Request;
17+
18+
class ContainerAwareHIncludeFragmentRendererTest extends TestCase
19+
{
20+
public function testRender()
21+
{
22+
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
23+
$container->expects($this->once())
24+
->method('get')
25+
->will($this->returnValue($this->getMock('\Twig_Environment')))
26+
;
27+
$renderer = new ContainerAwareHIncludeFragmentRenderer($container);
28+
$renderer->render('/', Request::create('/'));
29+
}
30+
}

src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ public function setTemplating($templating)
5656
$this->templating = $templating;
5757
}
5858

59+
/**
60+
* Checks if a templating engine has been set.
61+
*
62+
* @return Boolean true if the templating engine has been set, false otherwise
63+
*/
64+
public function hasTemplating()
65+
{
66+
return null !== $this->templating;
67+
}
68+
5969
/**
6070
* {@inheritdoc}
6171
*

0 commit comments

Comments
 (0)