Skip to content

Commit

Permalink
Merge pull request #624 from usu/fix/twig-optional
Browse files Browse the repository at this point in the history
fix: treat Twig as optional
  • Loading branch information
dbu committed May 3, 2024
2 parents 8ab0ed8 + 6be0262 commit 4a542b3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/DependencyInjection/FOSHttpCacheExtension.php
Expand Up @@ -29,6 +29,7 @@
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Twig\TwigFunction;

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

$loader->load('cache_tagging.xml');
if (class_exists(TwigFunction::class)) {
$loader->load('cache_tagging_twig.xml');
}
if (class_exists(Application::class)) {
$loader->load('cache_tagging_commands.xml');
}
Expand Down
5 changes: 0 additions & 5 deletions src/Resources/config/cache_tagging.xml
Expand Up @@ -21,11 +21,6 @@

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

<service id="fos_http_cache.twig.tag_extension" class="FOS\HttpCacheBundle\Twig\CacheTagExtension">
<argument id="fos_http_cache.http.symfony_response_tagger" type="service"/>
<tag name="twig.extension"/>
</service>

<service id="fos_http_cache.event_listener.tag" class="FOS\HttpCacheBundle\EventListener\TagListener">
<argument type="service" id="fos_http_cache.cache_manager" />
<argument type="service" id="fos_http_cache.http.symfony_response_tagger" />
Expand Down
13 changes: 13 additions & 0 deletions src/Resources/config/cache_tagging_twig.xml
@@ -0,0 +1,13 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="fos_http_cache.twig.tag_extension" class="FOS\HttpCacheBundle\Twig\CacheTagExtension">
<argument id="fos_http_cache.http.symfony_response_tagger" type="service"/>
<tag name="twig.extension"/>
</service>
</services>
</container>

0 comments on commit 4a542b3

Please sign in to comment.