Skip to content

Commit 31131c7

Browse files
fix: Support new $cacheId with versions (#37)
1 parent 0d3bbe9 commit 31131c7

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/StatiCache.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,18 @@ protected static function parseCacheId(string $key): array
148148

149149
$parts = explode('.', $key);
150150
$contentType = array_pop($parts);
151-
$language = $kirby->multilang() === true ? array_pop($parts) : null;
152-
$id = implode('.', $parts);
153151

154-
return compact('id', 'language', 'contentType');
152+
// Check for the new Version API in Kirby 5
153+
// Split a cache ID into `$id.$language.$version.$contentType`
154+
if (class_exists('Kirby\Content\Version') === true) {
155+
$version = array_pop($parts);
156+
} else {
157+
$version = null;
158+
}
159+
160+
$language = $kirby->multilang() === true ? array_pop($parts) : null;
161+
$id = implode('.', $parts);
162+
163+
return compact('id', 'language', 'contentType', 'version');
155164
}
156165
}

0 commit comments

Comments
 (0)