1 | <?php |
||
25 | class CacheManager |
||
26 | { |
||
27 | /** |
||
28 | * @var FilterConfiguration |
||
29 | */ |
||
30 | protected $filterConfig; |
||
31 | |||
32 | /** |
||
33 | * @var RouterInterface |
||
34 | */ |
||
35 | protected $router; |
||
36 | |||
37 | /** |
||
38 | * @var ResolverInterface[] |
||
39 | */ |
||
40 | protected $resolvers = []; |
||
41 | |||
42 | /** |
||
43 | * @var SignerInterface |
||
44 | */ |
||
45 | protected $signer; |
||
46 | |||
47 | /** |
||
48 | * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface |
||
49 | */ |
||
50 | protected $dispatcher; |
||
51 | |||
52 | /** |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $defaultResolver; |
||
56 | |||
57 | /** |
||
58 | * Constructs the cache manager to handle Resolvers based on the provided FilterConfiguration. |
||
59 | * |
||
60 | * @param string $defaultResolver |
||
61 | */ |
||
62 | public function __construct( |
||
75 | |||
76 | /** |
||
77 | * Adds a resolver to handle cached images for the given filter. |
||
78 | * |
||
79 | * @param string $filter |
||
80 | */ |
||
81 | public function addResolver($filter, ResolverInterface $resolver) |
||
89 | |||
90 | /** |
||
91 | * Gets filtered path for rendering in the browser. |
||
92 | * It could be the cached one or an url of filter action. |
||
93 | * |
||
94 | * @param string $path The path where the resolved file is expected |
||
95 | * @param string $filter |
||
96 | * @param string $resolver |
||
97 | * @param int $referenceType |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | public function getBrowserPath($path, $filter, array $runtimeConfig = [], $resolver = null, $referenceType = UrlGeneratorInterface::ABSOLUTE_URL) |
||
115 | |||
116 | /** |
||
117 | * Get path to runtime config image. |
||
118 | * |
||
119 | * @param string $path |
||
120 | * |
||
121 | * @return string |
||
122 | */ |
||
123 | public function getRuntimePath($path, array $runtimeConfig) |
||
127 | |||
128 | /** |
||
129 | * Returns a web accessible URL. |
||
130 | * |
||
131 | * @param string $path The path where the resolved file is expected |
||
132 | * @param string $filter The name of the imagine filter in effect |
||
133 | * @param string $resolver |
||
134 | * @param int $referenceType The type of reference to be generated (one of the UrlGenerator constants) |
||
135 | * |
||
136 | * @return string |
||
137 | */ |
||
138 | public function generateUrl($path, $filter, array $runtimeConfig = [], $resolver = null, $referenceType = UrlGeneratorInterface::ABSOLUTE_URL) |
||
160 | |||
161 | /** |
||
162 | * Checks whether the path is already stored within the respective Resolver. |
||
163 | * |
||
164 | * @param string $path |
||
165 | * @param string $filter |
||
166 | * @param string $resolver |
||
167 | * |
||
168 | * @return bool |
||
169 | */ |
||
170 | public function isStored($path, $filter, $resolver = null) |
||
174 | |||
175 | /** |
||
176 | * Resolves filtered path for rendering in the browser. |
||
177 | * |
||
178 | * @param string $path |
||
179 | * @param string $filter |
||
180 | * @param string $resolver |
||
181 | * |
||
182 | * @throws NotFoundHttpException if the path can not be resolved |
||
183 | * |
||
184 | * @return string The url of resolved image |
||
185 | */ |
||
186 | public function resolve($path, $filter, $resolver = null) |
||
202 | |||
203 | /** |
||
204 | * @see ResolverInterface::store |
||
205 | * |
||
206 | * @param string $path |
||
207 | * @param string $filter |
||
208 | * @param string $resolver |
||
209 | */ |
||
210 | public function store(BinaryInterface $binary, $path, $filter, $resolver = null) |
||
214 | |||
215 | /** |
||
216 | * @param string|string[]|null $paths |
||
217 | * @param string|string[]|null $filters |
||
218 | */ |
||
219 | public function remove($paths = null, $filters = null) |
||
248 | |||
249 | /** |
||
250 | * Gets a resolver for the given filter. |
||
251 | * |
||
252 | * In case there is no specific resolver, but a default resolver has been configured, the default will be returned. |
||
253 | * |
||
254 | * @param string $filter |
||
255 | * @param string $resolver |
||
256 | * |
||
257 | * @throws \OutOfBoundsException If neither a specific nor a default resolver is available |
||
258 | * |
||
259 | * @return ResolverInterface |
||
260 | */ |
||
261 | protected function getResolver($filter, $resolver) |
||
278 | |||
279 | /** |
||
280 | * BC Layer for Symfony < 4.3 |
||
281 | */ |
||
282 | private function dispatchWithBC(CacheResolveEvent $event, string $eventName): void |
||
290 | } |
||
291 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: