Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Fabien Potencier <fabien@symfony.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
 
12
namespace Symfony\Component\HttpKernel\CacheClearer;
13
 
14
use Psr\Cache\CacheItemPoolInterface;
15
 
16
/**
17
 * @author Nicolas Grekas <p@tchwork.com>
18
 */
19
class Psr6CacheClearer implements CacheClearerInterface
20
{
21
    private array $pools = [];
22
 
23
    /**
24
     * @param array<string, CacheItemPoolInterface> $pools
25
     */
26
    public function __construct(array $pools = [])
27
    {
28
        $this->pools = $pools;
29
    }
30
 
31
    public function hasPool(string $name): bool
32
    {
33
        return isset($this->pools[$name]);
34
    }
35
 
36
    /**
37
     * @throws \InvalidArgumentException If the cache pool with the given name does not exist
38
     */
39
    public function getPool(string $name): CacheItemPoolInterface
40
    {
41
        if (!$this->hasPool($name)) {
42
            throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name));
43
        }
44
 
45
        return $this->pools[$name];
46
    }
47
 
48
    /**
49
     * @throws \InvalidArgumentException If the cache pool with the given name does not exist
50
     */
51
    public function clearPool(string $name): bool
52
    {
53
        if (!isset($this->pools[$name])) {
54
            throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name));
55
        }
56
 
57
        return $this->pools[$name]->clear();
58
    }
59
 
60
    public function clear(string $cacheDir)
61
    {
62
        foreach ($this->pools as $pool) {
63
            $pool->clear();
64
        }
65
    }
66
}