Total Complexity | 5 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
11 | class AddAllFilesFromDiskToDB extends BuildTask |
||
12 | { |
||
13 | |||
14 | protected $title = 'Add all files from disk to database'; |
||
15 | |||
16 | protected $description = 'This task will add all files from the disk to the database.'; |
||
17 | |||
18 | private static $segment = 'add-all-files-from-disk-to-db'; |
||
19 | |||
20 | protected $dryRun = true; |
||
21 | |||
22 | public function run($request) |
||
23 | { |
||
24 | $this->dryRun = $request->getVar('forreal') ? false : true; |
||
25 | $this->dryRunMessage(); |
||
26 | |||
27 | $files = AllFilesInfo::inst()->getAllFiles(); |
||
28 | $obj = Injector::inst()->get(AddAndRemoveFromDb::class); |
||
29 | $obj->setIsDryRun($this->dryRun); |
||
30 | foreach ($files as $file) { |
||
31 | $array = $file->toMap(); |
||
32 | $obj->run($array, 'add'); |
||
33 | } |
||
34 | $this->dryRunMessage(); |
||
35 | DB::alteration_message('=== DONE ===', ''); |
||
36 | } |
||
37 | |||
38 | |||
39 | protected function dryRunMessage() |
||
45 | } |
||
46 | } |
||
48 |