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:
Sam Minnee 2010-01-13 00:06:38 +00:00
parent 0cdd75dfb1
commit adfab8b55f

View File

@ -221,6 +221,32 @@ class FilesystemPublisher extends StaticPublisher {
public function getDestDir() { public function getDestDir() {
return '../'.$this->destFolder; 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;
}
} }
?> ?>