1 | <?php |
||
8 | class Asset extends AbstractHelper |
||
9 | { |
||
10 | /** |
||
11 | * @var array |
||
12 | */ |
||
13 | private $config; |
||
14 | |||
15 | /** @var null|AbstractCacheAdapter */ |
||
16 | private $cache; |
||
17 | |||
18 | /** |
||
19 | * @var ResolverInterface |
||
20 | */ |
||
21 | private $assetManagerResolver; |
||
22 | |||
23 | /** |
||
24 | * @param ResolverInterface $assetManagerResolver |
||
25 | * @param AbstractCacheAdapter|null $cache |
||
26 | * @param array $config |
||
27 | */ |
||
28 | 4 | public function __construct(ResolverInterface $assetManagerResolver, $cache, $config) |
|
34 | |||
35 | /** |
||
36 | * Append timestamp as query param to the filename |
||
37 | * |
||
38 | * @param string $filename |
||
39 | * @param string $queryString |
||
40 | * @param int|null $timestamp |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | 2 | private function appendTimestamp($filename, $queryString, $timestamp = null) |
|
51 | |||
52 | /** |
||
53 | * find the file and if it exists, append its unix modification time to the filename |
||
54 | * |
||
55 | * @param string $filename |
||
56 | * @param string $queryString |
||
57 | * @return string |
||
58 | */ |
||
59 | 1 | private function elaborateFilePath($filename, $queryString) |
|
69 | |||
70 | /** |
||
71 | * Use the cache to get the filePath |
||
72 | * |
||
73 | * @param string $filename |
||
74 | * @param string $queryString |
||
75 | * |
||
76 | * @return mixed|string |
||
77 | */ |
||
78 | 1 | private function getFilePathFromCache($filename, $queryString) |
|
98 | |||
99 | /** |
||
100 | * Output the filepath with its unix modification time as query param |
||
101 | * |
||
102 | * @param string $filename |
||
103 | * @return string |
||
104 | */ |
||
105 | 3 | public function __invoke($filename) |
|
138 | } |
||
139 |