Skip to content

Commit

Permalink
Symfony Client: Support Tags: Check if needed dependency is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
trickreich authored and dbu committed Sep 10, 2018
1 parent 6552fb1 commit 9a70383
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Changelog

See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpCache/releases).

2.5.1
-----

### Symfony

* Have cache invalidator check for presence of Psr6Store for a better guess
whether the cache really is TagCapable or not.

2.5.0
-----

Expand Down
9 changes: 8 additions & 1 deletion src/CacheInvalidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
use FOS\HttpCache\ProxyClient\Invalidation\RefreshCapable;
use FOS\HttpCache\ProxyClient\Invalidation\TagCapable;
use FOS\HttpCache\ProxyClient\ProxyClient;
use FOS\HttpCache\ProxyClient\Symfony;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Toflar\Psr6HttpCacheStore\Psr6Store;

/**
* Manages HTTP cache invalidation.
Expand Down Expand Up @@ -97,7 +99,12 @@ public function supports($operation)
case self::INVALIDATE:
return $this->cache instanceof BanCapable;
case self::TAGS:
return $this->cache instanceof TagCapable;
$supports = $this->cache instanceof TagCapable;
if ($supports && $this->cache instanceof Symfony) {
return class_exists(Psr6Store::class);
}

return $supports;
default:
throw new InvalidArgumentException('Unknown operation '.$operation);
}
Expand Down

0 comments on commit 9a70383

Please sign in to comment.