1 | <?php |
||
20 | class PsrCacheResolver implements ResolverInterface |
||
21 | { |
||
22 | private const RESERVED_CHARACTERS = [ |
||
23 | '{', |
||
24 | '}', |
||
25 | '(', |
||
26 | ')', |
||
27 | '/', |
||
28 | '\\', |
||
29 | '@', |
||
30 | ':', |
||
31 | '.', |
||
32 | ]; |
||
33 | |||
34 | /** |
||
35 | * @var CacheItemPoolInterface |
||
36 | */ |
||
37 | protected $cache; |
||
38 | |||
39 | /** |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $options = []; |
||
43 | |||
44 | /** |
||
45 | * @var ResolverInterface |
||
46 | */ |
||
47 | protected $resolver; |
||
48 | |||
49 | /** |
||
50 | * Constructor. |
||
51 | * |
||
52 | * Available options: |
||
53 | * * global_prefix |
||
54 | * A prefix for all keys within the cache. This is useful to avoid colliding keys when using the same cache for different systems. |
||
55 | * * prefix |
||
56 | * A "local" prefix for this wrapper. This is useful when re-using the same resolver for multiple filters. |
||
57 | * * index_key |
||
58 | * The name of the index key being used to save a list of created cache keys regarding one image and filter pairing. |
||
59 | * |
||
60 | * @param OptionsResolver $optionsResolver |
||
61 | */ |
||
62 | public function __construct(CacheItemPoolInterface $cache, ResolverInterface $cacheResolver, array $options = [], OptionsResolver $optionsResolver = null) |
||
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | public function isStored($path, $filter) |
||
86 | |||
87 | /** |
||
88 | * {@inheritdoc} |
||
89 | */ |
||
90 | public function resolve($path, $filter) |
||
105 | |||
106 | /** |
||
107 | * {@inheritdoc} |
||
108 | */ |
||
109 | public function store(BinaryInterface $binary, $path, $filter) |
||
113 | |||
114 | /** |
||
115 | * {@inheritdoc} |
||
116 | */ |
||
117 | public function remove(array $paths, array $filters) |
||
131 | |||
132 | /** |
||
133 | * Generate a unique cache key based on the given parameters. |
||
134 | * |
||
135 | * When overriding this method, ensure generateIndexKey is adjusted accordingly. |
||
136 | * |
||
137 | * @param string $path The image path in use |
||
138 | * @param string $filter The filter in use |
||
139 | * |
||
140 | * @return string |
||
141 | */ |
||
142 | public function generateCacheKey($path, $filter) |
||
151 | |||
152 | protected function removePathAndFilter($path, $filter) |
||
183 | |||
184 | /** |
||
185 | * Generate the index key for the given cacheKey. |
||
186 | * |
||
187 | * The index contains a list of cache keys related to an image and a filter. |
||
188 | * |
||
189 | * @param string $cacheKey |
||
190 | * |
||
191 | * @return string |
||
192 | */ |
||
193 | protected function generateIndexKey($cacheKey) |
||
204 | |||
205 | /** |
||
206 | * @param string $cacheKeyPart |
||
207 | * |
||
208 | * @return string |
||
209 | */ |
||
210 | protected function sanitizeCacheKeyPart($cacheKeyPart) |
||
214 | |||
215 | /** |
||
216 | * Save the given content to the cache and update the cache index. |
||
217 | * |
||
218 | * @return bool |
||
219 | */ |
||
220 | protected function saveToCache(CacheItemInterface $item) |
||
243 | |||
244 | protected function configureOptions(OptionsResolver $resolver) |
||
262 | |||
263 | protected function setDefaultOptions(OptionsResolver $resolver) |
||
267 | } |
||
268 |