Move rebuildstaticcache to a standard buildtask

This commit is contained in:
Will Rossiter 2012-09-21 19:49:46 +12:00
parent ba6e935177
commit 3a40e7a74b

View File

@ -1,26 +1,10 @@
<?php
/**
* @package cms
* @subpackage tasks
*
* @todo Make this use the Task interface once it gets merged back into trunk
* @package static
*/
class RebuildStaticCacheTask extends Controller {
class RebuildStaticCacheTask extends BuildTask {
static $allowed_actions = array(
'index',
);
function init() {
parent::init();
Versioned::reading_stage('live');
$canAccess = (Director::isDev() || Director::is_cli() || Permission::check("ADMIN"));
if(!$canAccess) return Security::permissionFailure($this);
}
function index() {
public function run($request) {
StaticPublisher::set_echo_progress(true);
$page = singleton('Page');
@ -97,6 +81,7 @@ class RebuildStaticCacheTask extends Controller {
foreach(glob(BASE_PATH . '/cache/*', GLOB_ONLYDIR) as $cacheDir) {
foreach(glob($cacheDir.'/*') as $cacheFile) {
$searchCacheFile = trim(str_replace($cacheBaseDir, '', $cacheFile), '\/');
if (!in_array($searchCacheFile, $mappedUrls)) {
echo " * Deleting $cacheFile\n";
@unlink($cacheFile);
@ -116,11 +101,4 @@ class RebuildStaticCacheTask extends Controller {
echo "\n\n== Done! ==";
}
function show() {
$urls = singleton('Page')->allPagesToCache();
echo "<pre>\n";
print_r($urls);
echo "\n</pre>";
}
}