Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\HttpKernel\CacheClearer; Chris@0: Chris@0: use Psr\Cache\CacheItemPoolInterface; Chris@0: Chris@0: /** Chris@0: * @author Nicolas Grekas
Chris@0: */ Chris@0: class Psr6CacheClearer implements CacheClearerInterface Chris@0: { Chris@17: private $pools = []; Chris@0: Chris@17: public function __construct(array $pools = []) Chris@14: { Chris@14: $this->pools = $pools; Chris@14: } Chris@14: Chris@0: public function addPool(CacheItemPoolInterface $pool) Chris@0: { Chris@14: @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Pass an array of pools indexed by name to the constructor instead.', __METHOD__), E_USER_DEPRECATED); Chris@14: Chris@0: $this->pools[] = $pool; Chris@0: } Chris@0: Chris@14: public function hasPool($name) Chris@14: { Chris@14: return isset($this->pools[$name]); Chris@14: } Chris@14: Chris@14: public function clearPool($name) Chris@14: { Chris@14: if (!isset($this->pools[$name])) { Chris@14: throw new \InvalidArgumentException(sprintf('Cache pool not found: %s.', $name)); Chris@14: } Chris@14: Chris@14: return $this->pools[$name]->clear(); Chris@14: } Chris@14: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function clear($cacheDir) Chris@0: { Chris@0: foreach ($this->pools as $pool) { Chris@0: $pool->clear(); Chris@0: } Chris@0: } Chris@0: }