1 | <?php |
||
7 | abstract class PoolDecorator implements CacheItemPoolInterface |
||
8 | { |
||
9 | /** @var CacheItemPoolInterface */ |
||
10 | private $decorated; |
||
11 | |||
12 | 882 | public function __construct(CacheItemPoolInterface $decorated) |
|
16 | |||
17 | 462 | public function getItem($key) |
|
21 | |||
22 | 156 | public function hasItem($key) |
|
26 | |||
27 | public function getItems(array $keys = []) |
||
28 | { |
||
29 | 126 | return array_map(function (CacheItemInterface $inner) { |
|
30 | 18 | return $this->decorate($inner); |
|
31 | 126 | }, $this->decorated->getItems($keys)); |
|
32 | } |
||
33 | |||
34 | 876 | public function clear() |
|
38 | |||
39 | 114 | public function deleteItems(array $keys) |
|
43 | |||
44 | 126 | 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 | 48 | public function commit() |
|
74 | |||
75 | abstract protected function decorate(CacheItemInterface $inner); |
||
76 | } |
||
77 |