merged branch fabpot/circular-reference-fix (PR #6850)

This PR was merged into the master branch.

Commits
-------

65b4112 fixed a circular reference (closes #6730)

Discussion
----------

fixed a circular reference (closes #6730)

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #6730
| License       | MIT
| Doc PR        | n/a

---------------------------------------------------------------------------

by stof at 2013-01-23T13:56:19Z

shoudln't this be moved to the component ? Someone using the TwigBridge, HttpKernel and the DI component outside the full stack framework (let's say Drupal maybe) would also face the circular reference issue

---------------------------------------------------------------------------

by fabpot at 2013-01-23T13:58:28Z

No, they won't as the problem is only if you are using the templating component. So, Silex or Drupal won't have the problem.

---------------------------------------------------------------------------

by stof at 2013-01-23T14:01:03Z

ah, the issue is indeed with the TwigEngine, not with the Twig_Environment service.
This commit is contained in:
Fabien Potencier 2013-01-23 17:07:19 +01:00
commit 2cc3331a6f
3 changed files with 53 additions and 3 deletions

View File

@ -0,0 +1,49 @@
<?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\RenderingStrategy;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\UriSigner;
use Symfony\Component\HttpKernel\RenderingStrategy\HIncludeRenderingStrategy;
/**
* Implements the Hinclude rendering strategy.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ContainerAwareHIncludeRenderingStrategy extends HIncludeRenderingStrategy
{
private $container;
/**
* {@inheritdoc}
*/
public function __construct(ContainerInterface $container, UriSigner $signer = null, $globalDefaultTemplate = null)
{
$this->container = $container;
parent::__construct(null, $signer, $globalDefaultTemplate);
}
/**
* {@inheritdoc}
*/
public function render($uri, Request $request, array $options = array())
{
if (!$this->templating) {
$this->templating = $this->container->get('templating');
}
return parent::render($uri, $request, $options);
}
}

View File

@ -7,7 +7,7 @@
<parameters>
<parameter key="http_content_renderer.class">Symfony\Component\HttpKernel\HttpContentRenderer</parameter>
<parameter key="http_content_renderer.strategy.default.class">Symfony\Component\HttpKernel\RenderingStrategy\DefaultRenderingStrategy</parameter>
<parameter key="http_content_renderer.strategy.hinclude.class">Symfony\Component\HttpKernel\RenderingStrategy\HIncludeRenderingStrategy</parameter>
<parameter key="http_content_renderer.strategy.hinclude.class">Symfony\Bundle\FrameworkBundle\RenderingStrategy\ContainerAwareHIncludeRenderingStrategy</parameter>
<parameter key="http_content_renderer.strategy.hinclude.global_template"></parameter>
<parameter key="http_content_renderer.proxy_path">/_proxy</parameter>
</parameters>
@ -27,7 +27,7 @@
<service id="http_content_renderer.strategy.hinclude" class="%http_content_renderer.strategy.hinclude.class%">
<tag name="kernel.content_renderer_strategy" />
<argument type="service" id="templating" on-invalid="null" />
<argument type="service" id="service_container" />
<argument type="service" id="uri_signer" />
<argument>%http_content_renderer.strategy.hinclude.global_template%</argument>
<call method="setProxyPath"><argument>%http_content_renderer.proxy_path%</argument></call>

View File

@ -24,7 +24,8 @@ use Symfony\Component\HttpKernel\UriSigner;
*/
class HIncludeRenderingStrategy extends ProxyAwareRenderingStrategy
{
private $templating;
protected $templating;
private $globalDefaultTemplate;
private $signer;