1 | <?php |
||
7 | abstract class PoolDecorator implements CacheItemPoolInterface |
||
8 | { |
||
9 | /** @var CacheItemPoolInterface */ |
||
10 | private $decorated; |
||
11 | |||
12 | 1308 | public function __construct(CacheItemPoolInterface $decorated) |
|
16 | |||
17 | 684 | public function getItem($key) |
|
21 | |||
22 | 231 | public function hasItem($key) |
|
26 | |||
27 | public function getItems(array $keys = []) |
||
28 | { |
||
29 | 189 | return array_map(function (CacheItemInterface $inner) { |
|
30 | 27 | return $this->decorate($inner); |
|
31 | 189 | }, $this->decorated->getItems($keys)); |
|
32 | } |
||
33 | |||
34 | 1299 | public function clear() |
|
38 | |||
39 | 171 | public function deleteItems(array $keys) |
|
43 | |||
44 | 189 | public function deleteItem($key) |
|
48 | |||
49 | 162 | public function save(CacheItemInterface $item) |
|
53 | |||
54 | 90 | public function saveDeferred(CacheItemInterface $item) |
|
58 | |||
59 | 252 | private function proxySave(CacheItemInterface $item, $deferred = false) |
|
60 | { |
||
61 | 252 | if ($item instanceof ItemDecorator) { |
|
62 | 180 | return $this->decorated |
|
63 | 180 | ->{$deferred ? 'saveDeferred' : 'save'}($item->getDecorated()); |
|
64 | } |
||
65 | |||
66 | 72 | throw new InvalidArgumentException('The provided cache item cannot' |
|
67 | 72 | . ' be saved, as it did not originate from this cache.'); |
|
68 | } |
||
69 | |||
70 | 72 | public function commit() |
|
74 | |||
75 | abstract protected function decorate(CacheItemInterface $inner); |
||
76 | } |
||
77 |