@@ -25,6 +25,8 @@ class ResourceCheckerConfigCache implements ConfigCacheInterface
25
25
{
26
26
private string $ file ;
27
27
28
+ private string $ metaFile ;
29
+
28
30
/**
29
31
* @var iterable<mixed, ResourceCheckerInterface>
30
32
*/
@@ -33,11 +35,13 @@ class ResourceCheckerConfigCache implements ConfigCacheInterface
33
35
/**
34
36
* @param string $file The absolute cache path
35
37
* @param iterable<mixed, ResourceCheckerInterface> $resourceCheckers The ResourceCheckers to use for the freshness check
38
+ * @param string|null $metaFile The absolute path to the meta file, defaults to $file.meta if null
36
39
*/
37
- public function __construct (string $ file , iterable $ resourceCheckers = [])
40
+ public function __construct (string $ file , iterable $ resourceCheckers = [], string $ metaFile = null )
38
41
{
39
42
$ this ->file = $ file ;
40
43
$ this ->resourceCheckers = $ resourceCheckers ;
44
+ $ this ->metaFile = $ metaFile ?? $ file .'.meta ' ;
41
45
}
42
46
43
47
public function getPath (): string
@@ -68,7 +72,7 @@ public function isFresh(): bool
68
72
return true ; // shortcut - if we don't have any checkers we don't need to bother with the meta file at all
69
73
}
70
74
71
- $ metadata = $ this ->getMetaFile () ;
75
+ $ metadata = $ this ->metaFile ;
72
76
73
77
if (!is_file ($ metadata )) {
74
78
return false ;
@@ -120,9 +124,9 @@ public function write(string $content, array $metadata = null): void
120
124
}
121
125
122
126
if (null !== $ metadata ) {
123
- $ filesystem ->dumpFile ($ this ->getMetaFile () , serialize ($ metadata ));
127
+ $ filesystem ->dumpFile ($ this ->metaFile , serialize ($ metadata ));
124
128
try {
125
- $ filesystem ->chmod ($ this ->getMetaFile () , $ mode , $ umask );
129
+ $ filesystem ->chmod ($ this ->metaFile , $ mode , $ umask );
126
130
} catch (IOException ) {
127
131
// discard chmod failure (some filesystem may not support it)
128
132
}
@@ -133,14 +137,6 @@ public function write(string $content, array $metadata = null): void
133
137
}
134
138
}
135
139
136
- /**
137
- * Gets the meta file path.
138
- */
139
- private function getMetaFile (): string
140
- {
141
- return $ this ->file .'.meta ' ;
142
- }
143
-
144
140
private function safelyUnserialize (string $ file ): mixed
145
141
{
146
142
$ meta = false ;
0 commit comments