Skip to content

Commit 4a542b3

Browse files
authored
Merge pull request #624 from usu/fix/twig-optional
fix: treat Twig as optional
2 parents 8ab0ed8 + 6be0262 commit 4a542b3

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/DependencyInjection/FOSHttpCacheExtension.php

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use Symfony\Component\DependencyInjection\Reference;
3030
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
3131
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
32+
use Twig\TwigFunction;
3233

3334
final class FOSHttpCacheExtension extends Extension
3435
{
@@ -524,6 +525,9 @@ private function loadCacheTagging(ContainerBuilder $container, XmlFileLoader $lo
524525
$container->setParameter('fos_http_cache.tag_handler.strict', $config['strict']);
525526

526527
$loader->load('cache_tagging.xml');
528+
if (class_exists(TwigFunction::class)) {
529+
$loader->load('cache_tagging_twig.xml');
530+
}
527531
if (class_exists(Application::class)) {
528532
$loader->load('cache_tagging_commands.xml');
529533
}

src/Resources/config/cache_tagging.xml

-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121

2222
<service id="FOS\HttpCache\ResponseTagger" alias="fos_http_cache.http.symfony_response_tagger" public="true"/>
2323

24-
<service id="fos_http_cache.twig.tag_extension" class="FOS\HttpCacheBundle\Twig\CacheTagExtension">
25-
<argument id="fos_http_cache.http.symfony_response_tagger" type="service"/>
26-
<tag name="twig.extension"/>
27-
</service>
28-
2924
<service id="fos_http_cache.event_listener.tag" class="FOS\HttpCacheBundle\EventListener\TagListener">
3025
<argument type="service" id="fos_http_cache.cache_manager" />
3126
<argument type="service" id="fos_http_cache.http.symfony_response_tagger" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" ?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6+
7+
<services>
8+
<service id="fos_http_cache.twig.tag_extension" class="FOS\HttpCacheBundle\Twig\CacheTagExtension">
9+
<argument id="fos_http_cache.http.symfony_response_tagger" type="service"/>
10+
<tag name="twig.extension"/>
11+
</service>
12+
</services>
13+
</container>

0 commit comments

Comments
 (0)