API CHANGE: Added FilesystemPublisher::getExistingStaticCacheFiles(), to help build caching logic methods. (from r91354) (from r96810)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@102673 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-04-13 03:52:00 +00:00
parent 1e972ed695
commit b367ecd2d4

View File

@ -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;
}
}
?>