PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 4.3.0
WP STAGING – WordPress Backup, Restore, Migration & Clone v4.3.0
4.9.3 4.9.2 4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Backup / Task / FileBackupTask.php
wp-staging / Backup / Task Last commit date
Tasks 11 months ago BackupTask.php 1 year ago FileBackupTask.php 11 months ago FileRestoreTask.php 1 year ago RestoreTask.php 1 year ago
FileBackupTask.php
70 lines
1 <?php
2
3 // TODO PHP7.1; constant visibility
4
5 namespace WPStaging\Backup\Task;
6
7 use WPStaging\Backup\Service\FileBackupService;
8 use WPStaging\Backup\Service\FileBackupServiceProvider;
9 use WPStaging\Backup\Task\BackupTask;
10 use WPStaging\Framework\Job\Dto\StepsDto;
11 use WPStaging\Framework\Job\Dto\TaskResponseDto;
12 use WPStaging\Framework\Queue\SeekableQueueInterface;
13 use WPStaging\Framework\Utils\Cache\Cache;
14 use WPStaging\Vendor\Psr\Log\LoggerInterface;
15
16 abstract class FileBackupTask extends BackupTask
17 {
18 /** @var FileBackupService */
19 protected $fileBackupService;
20
21 public function __construct(FileBackupServiceProvider $fileBackupServiceProvider, LoggerInterface $logger, Cache $cache, StepsDto $stepsDto, SeekableQueueInterface $taskQueue)
22 {
23 parent::__construct($logger, $cache, $stepsDto, $taskQueue);
24 $this->fileBackupService = $fileBackupServiceProvider->getService(); // @phpstan-ignore-line
25 }
26
27 public static function getTaskName(): string
28 {
29 return 'backup_file_task';
30 }
31
32 public static function getTaskTitle(): string
33 {
34 return 'Adding Files to Backup';
35 }
36
37 public function execute(): TaskResponseDto
38 {
39 $this->prepareFileBackupTask();
40 $this->fileBackupService->setupArchiver($this->getFileIdentifier(), $this->isOtherWpRootFilesTask());
41 $this->fileBackupService->execute();
42
43 return $this->generateResponse(false);
44 }
45
46 /** @return string */
47 abstract protected function getFileIdentifier(): string;
48
49 /**
50 * @return void
51 */
52 private function prepareFileBackupTask()
53 {
54 $this->fileBackupService->inject($this->taskQueue, $this->logger, $this->jobDataDto, $this->stepsDto);
55 if ($this->stepsDto->getTotal() > 0) {
56 return;
57 }
58
59 $this->stepsDto->setTotal($this->jobDataDto->getDiscoveredFilesByCategory($this->getFileIdentifier()));
60 }
61
62 /**
63 * @return bool
64 */
65 protected function isOtherWpRootFilesTask(): bool
66 {
67 return false;
68 }
69 }
70