IMPR: Clean page content fields task

This commit is contained in:
Tony Air 2020-12-28 17:38:30 +07:00
parent 4eeed7a894
commit ba534a3f18

View File

@ -0,0 +1,29 @@
<?php
namespace Site\Tasks;
use SilverStripe\Assets\File;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Dev\BuildTask;
class CleanContentTask extends BuildTask
{
protected $title = 'Clean content task';
protected $description = 'Clean content task';
protected $enabled = true;
public function run($request)
{
$pages = SiteTree::get();
foreach ($pages as $p) {
$p->setField('Content', '');
$p->write();
echo '#'.$p->ID.' '.$p->getField('Title').'<br/>';
}
die('Done!');
}
}