mirror of
https://github.com/silverstripe/silverstripe-staticpublisher
synced 2024-10-22 12:05:54 +00:00
Move rebuildstaticcache to a standard buildtask
This commit is contained in:
parent
ba6e935177
commit
3a40e7a74b
@ -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>";
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user