2015-09-15 14:52:02 +12:00
|
|
|
<?php
|
|
|
|
|
2016-08-19 10:51:35 +12:00
|
|
|
namespace SilverStripe\Dev\Tasks;
|
|
|
|
|
2016-06-15 16:03:16 +12:00
|
|
|
use SilverStripe\ORM\DB;
|
2016-08-19 10:51:35 +12:00
|
|
|
use SilverStripe\Assets\FileMigrationHelper;
|
|
|
|
use SilverStripe\Dev\BuildTask;
|
2016-06-15 16:03:16 +12:00
|
|
|
|
2015-09-15 14:52:02 +12:00
|
|
|
/**
|
|
|
|
* Migrates all 3.x file dataobjects to use the new DBFile field.
|
|
|
|
*/
|
2016-11-29 12:31:16 +13:00
|
|
|
class MigrateFileTask extends BuildTask
|
|
|
|
{
|
2015-09-15 14:52:02 +12:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
private static $segment = 'MigrateFileTask';
|
2016-08-19 10:51:35 +12:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
protected $title = 'Migrate File dataobjects from 3.x';
|
2015-09-15 14:52:02 +12:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
protected $description
|
|
|
|
= 'Imports all files referenced by File dataobjects into the new Asset Persistence Layer introduced in 4.0';
|
2015-09-15 14:52:02 +12:00
|
|
|
|
2016-11-29 12:31:16 +13:00
|
|
|
public function run($request)
|
|
|
|
{
|
|
|
|
$migrated = FileMigrationHelper::singleton()->run();
|
|
|
|
if ($migrated) {
|
|
|
|
DB::alteration_message("{$migrated} File DataObjects upgraded", "changed");
|
|
|
|
} else {
|
|
|
|
DB::alteration_message("No File DataObjects need upgrading", "notice");
|
|
|
|
}
|
|
|
|
}
|
2015-09-15 14:52:02 +12:00
|
|
|
}
|