8000 made the content renderer work even when ESI is disabled or when no t… · symfony/symfony@bd102c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit bd102c5

Browse files
committed
made the content renderer work even when ESI is disabled or when no templating engine is available (the latter being mostly useful when testing)
1 parent a8ea4e4 commit bd102c5

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/content_generator.xml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<parameters>
88
<parameter key="http_content_renderer.class">Symfony\Component\HttpKernel\HttpContentRenderer</parameter>
99
<parameter key="http_content_renderer.strategy.default.class">Symfony\Component\HttpKernel\RenderingStrategy\DefaultRenderingStrategy</parameter>
10-
<parameter key="http_content_renderer.strategy.esi.class">Symfony\Component\HttpKernel\RenderingStrategy\EsiRenderingStrategy</parameter>
1110
<parameter key="http_content_renderer.strategy.hinclude.class">Symfony\Component\HttpKernel\RenderingStrategy\HIncludeRenderingStrategy</parameter>
1211
<parameter key="http_content_renderer.strategy.hinclude.global_template"></parameter>
1312
<parameter key="http_content_renderer.listener.router_proxy.class">Symfony\Component\HttpKernel\EventListener\RouterProxyListener</parameter>
@@ -26,17 +25,10 @@
2625
<call method="setUrlGenerator"><argument type="service" id="router" /></call>
2726
</service>
2827

29-
<service id="http_content_renderer.strategy.esi" class="%http_content_renderer.strategy.esi.class%" public="false">
30-
<tag name="kernel.content_renderer_strategy" />
31-
<argument type="service" id="esi" />
32-
<argument type="service" id="http_content_renderer.strategy.default" />
33-
<call method="setUrlGenerator"><argument type="service" id="router" /></call>
34-
</service>
35-
3628
<!-- FIXME: this service should be private but it cannot due to a bug in PhpDumper -->
3729
<service id="http_content_renderer.strategy.hinclude" class="%http_content_renderer.strategy.hinclude.class%">
3830
<tag name="kernel.content_renderer_strategy" />
39-
<argument type="service" id="templating" />
31+
<argument type="service" id="templating" on-invalid="null" />
4032
<argument type="service" id="uri_signer" />
4133
<argument>%http_content_renderer.strategy.hinclude.global_template%</argument>
4234
<call method="setUrlGenerator"><argument type="service" id="router" /></call>

src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<parameters>
88
<parameter key="esi.class">Symfony\Component\HttpKernel\HttpCache\Esi</parameter>
99
<parameter key="esi_listener.class">Symfony\Component\HttpKernel\EventListener\EsiListener</parameter>
10+
<parameter key="http_content_renderer.strategy.esi.class">Symfony\Component\HttpKernel\RenderingStrategy\EsiRenderingStrategy</parameter>
1011
</parameters>
1112

1213
<services>
@@ -16,5 +17,12 @@
1617
<tag name="kernel.event_subscriber" />
1718
<argument type="service" id="esi" on-invalid="ignore" />
1819
</service>
20+
21+
<service id="http_content_renderer.strategy.esi" class="%http_content_renderer.strategy.esi.class%" public="false">
22+
<tag name="kernel.content_renderer_strategy" />
23+
<argument type="service" id="esi" />
24+
<argument type="service" id="http_content_renderer.strategy.default" />
25+
<call method="setUrlGenerator"><argument type="service" id="router" /></call>
26+
</service>
1927
</services>
2028
</container>

src/Symfony/Component/HttpKernel/RenderingStrategy/HIncludeRenderingStrategy.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ class HIncludeRenderingStrategy extends GeneratorAwareRenderingStrategy
3434
* @param UriSigner $signer A UriSigner instance
3535
* @param string $globalDefaultTemplate The global default content (it can be a template name or the content)
3636
*/
37-
public function __construct($templating, UriSigner $signer = null, $globalDefaultTemplate = null)
37+
public function __construct($templating = null, UriSigner $signer = null, $globalDefaultTemplate = null)
3838
{
39-
if (!$templating instanceof EngineInterface && !$templating instanceof \Twig_Environment) {
39+
if (null !== $templating && !$templating instanceof EngineInterface && !$templating instanceof \Twig_Environment) {
4040
throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of \Twig_Environment or Symfony\Component\Templating\EngineInterface');
4141
}
4242

@@ -63,7 +63,7 @@ public function render($uri, Request $request = null, array $options = array())
6363
}
6464

6565
$template = isset($options['default']) ? $options['default'] : $this->globalDefaultTemplate;
66-
if ($this->templateExists($template)) {
66+
if (null !== $this->templating && $this->templateExists($template)) {
6767
$content = $this->templating->render($template);
6868
} else {
6969
$content = $template;

0 commit comments

Comments
 (0)
0