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
|
<?php
|
||||||
/**
|
/**
|
||||||
* @package cms
|
* @package static
|
||||||
* @subpackage tasks
|
|
||||||
*
|
|
||||||
* @todo Make this use the Task interface once it gets merged back into trunk
|
|
||||||
*/
|
*/
|
||||||
class RebuildStaticCacheTask extends Controller {
|
class RebuildStaticCacheTask extends BuildTask {
|
||||||
|
|
||||||
static $allowed_actions = array(
|
public function run($request) {
|
||||||
'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() {
|
|
||||||
StaticPublisher::set_echo_progress(true);
|
StaticPublisher::set_echo_progress(true);
|
||||||
|
|
||||||
$page = singleton('Page');
|
$page = singleton('Page');
|
||||||
@ -97,6 +81,7 @@ class RebuildStaticCacheTask extends Controller {
|
|||||||
foreach(glob(BASE_PATH . '/cache/*', GLOB_ONLYDIR) as $cacheDir) {
|
foreach(glob(BASE_PATH . '/cache/*', GLOB_ONLYDIR) as $cacheDir) {
|
||||||
foreach(glob($cacheDir.'/*') as $cacheFile) {
|
foreach(glob($cacheDir.'/*') as $cacheFile) {
|
||||||
$searchCacheFile = trim(str_replace($cacheBaseDir, '', $cacheFile), '\/');
|
$searchCacheFile = trim(str_replace($cacheBaseDir, '', $cacheFile), '\/');
|
||||||
|
|
||||||
if (!in_array($searchCacheFile, $mappedUrls)) {
|
if (!in_array($searchCacheFile, $mappedUrls)) {
|
||||||
echo " * Deleting $cacheFile\n";
|
echo " * Deleting $cacheFile\n";
|
||||||
@unlink($cacheFile);
|
@unlink($cacheFile);
|
||||||
@ -116,11 +101,4 @@ class RebuildStaticCacheTask extends Controller {
|
|||||||
|
|
||||||
echo "\n\n== Done! ==";
|
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