12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace Symfony\Component\HttpKernel\CacheClearer;
- use Psr\Cache\CacheItemPoolInterface;
- class Psr6CacheClearer implements CacheClearerInterface
- {
- private $pools = [];
-
- public function __construct(array $pools = [])
- {
- $this->pools = $pools;
- }
-
- public function hasPool(string $name)
- {
- return isset($this->pools[$name]);
- }
-
- public function getPool(string $name)
- {
- if (!$this->hasPool($name)) {
- throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name));
- }
- return $this->pools[$name];
- }
-
- public function clearPool(string $name)
- {
- if (!isset($this->pools[$name])) {
- throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name));
- }
- return $this->pools[$name]->clear();
- }
-
- public function clear(string $cacheDir)
- {
- foreach ($this->pools as $pool) {
- $pool->clear();
- }
- }
- }
|