Test Setup Failed
Push — master ( 210134...c17796 )
by Damian
03:18
created

src/Dev/Tasks/MigrateFileTask.php (1 issue)

1
<?php
2
3
namespace SilverStripe\Dev\Tasks;
4
5
use SilverStripe\AssetAdmin\Helper\ImageThumbnailHelper;
0 ignored issues
show
The type SilverStripe\AssetAdmin\...er\ImageThumbnailHelper was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use SilverStripe\ORM\DB;
7
use SilverStripe\Assets\FileMigrationHelper;
8
use SilverStripe\Dev\BuildTask;
9
10
/**
11
 * Migrates all 3.x file dataobjects to use the new DBFile field.
12
 */
13
class MigrateFileTask extends BuildTask
14
{
15
16
    private static $segment = 'MigrateFileTask';
17
18
    protected $title = 'Migrate File dataobjects from 3.x';
19
20
    protected $description
21
        = 'Imports all files referenced by File dataobjects into the new Asset Persistence Layer introduced in 4.0';
22
23
    public function run($request)
24
    {
25
        if (!class_exists(FileMigrationHelper::class)) {
26
            DB::alteration_message("No file migration helper detected", "notice");
27
            return;
28
        }
29
30
        $migrated = FileMigrationHelper::singleton()->run();
31
        if ($migrated) {
32
            DB::alteration_message("{$migrated} File DataObjects upgraded", "changed");
33
        } else {
34
            DB::alteration_message("No File DataObjects need upgrading", "notice");
35
        }
36
37
        if (!class_exists(ImageThumbnailHelper::class)) {
38
            DB::alteration_message("No image thumbnail helper detected", "notice");
39
            return;
40
        }
41
42
        ImageThumbnailHelper::singleton()->run();
43
    }
44
}
45