mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
API CHANGE: Added FilesystemPublisher::getExistingStaticCacheFiles(), to help build caching logic methods. (from r91354)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@96810 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
0cdd75dfb1
commit
adfab8b55f
@ -221,6 +221,32 @@ class FilesystemPublisher extends StaticPublisher {
|
||||
public function getDestDir() {
|
||||
return '../'.$this->destFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of all the existing static cache files, as a map of URL => file.
|
||||
* Only returns cache files that will actually map to a URL, based on urlsToPaths.
|
||||
*/
|
||||
public function getExistingStaticCacheFiles() {
|
||||
$cacheDir = '../'.$this->destFolder;
|
||||
|
||||
$urlMapper = array_flip($this->urlsToPaths($this->owner->allPagesToCache()));
|
||||
|
||||
$output = array();
|
||||
|
||||
// Glob each dir, then glob each one of those
|
||||
foreach(glob("$cacheDir/*", GLOB_ONLYDIR) as $cacheDir) {
|
||||
foreach(glob($cacheDir.'/*') as $cacheFile) {
|
||||
$mapKey = str_replace("../cache/","",$cacheFile);
|
||||
if(isset($urlMapper[$mapKey])) {
|
||||
$url = $urlMapper[$mapKey];
|
||||
$output[$url] = $cacheFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user