From 65b4112ddb29b23c5ca3ee2ebf20c2fd1ea338f9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 23 Jan 2013 14:48:08 +0100 Subject: [PATCH] fixed a circular reference (closes #6730) --- ...ontainerAwareHIncludeRenderingStrategy.php | 49 +++++++++++++++++++ .../Resources/config/content_generator.xml | 4 +- .../HIncludeRenderingStrategy.php | 3 +- 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/RenderingStrategy/ContainerAwareHIncludeRenderingStrategy.php diff --git a/src/Symfony/Bundle/FrameworkBundle/RenderingStrategy/ContainerAwareHIncludeRenderingStrategy.php b/src/Symfony/Bundle/FrameworkBundle/RenderingStrategy/ContainerAwareHIncludeRenderingStrategy.php new file mode 100644 index 0000000000..c1afd188b3 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/RenderingStrategy/ContainerAwareHIncludeRenderingStrategy.php @@ -0,0 +1,49 @@ + + * + * 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 + */ +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); + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/content_generator.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/content_generator.xml index 2a276c8c21..b9928df8c9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/content_generator.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/content_generator.xml @@ -7,7 +7,7 @@ Symfony\Component\HttpKernel\HttpContentRenderer Symfony\Component\HttpKernel\RenderingStrategy\DefaultRenderingStrategy - Symfony\Component\HttpKernel\RenderingStrategy\HIncludeRenderingStrategy + Symfony\Bundle\FrameworkBundle\RenderingStrategy\ContainerAwareHIncludeRenderingStrategy /_proxy @@ -27,7 +27,7 @@ - + %http_content_renderer.strategy.hinclude.global_template% %http_content_renderer.proxy_path% diff --git a/src/Symfony/Component/HttpKernel/RenderingStrategy/HIncludeRenderingStrategy.php b/src/Symfony/Component/HttpKernel/RenderingStrategy/HIncludeRenderingStrategy.php index 07a695635b..dd9f2d21fe 100644 --- a/src/Symfony/Component/HttpKernel/RenderingStrategy/HIncludeRenderingStrategy.php +++ b/src/Symfony/Component/HttpKernel/RenderingStrategy/HIncludeRenderingStrategy.php @@ -24,7 +24,8 @@ use Symfony\Component\HttpKernel\UriSigner; */ class HIncludeRenderingStrategy extends ProxyAwareRenderingStrategy { - private $templating; + protected $templating; + private $globalDefaultTemplate; private $signer;