Backup
2 years ago
FileList
2 years ago
Restore
3 years ago
Backup.php
2 years ago
BackupSpeedIndex.php
2 years ago
Cancel.php
3 years ago
Delete.php
3 years ago
Edit.php
3 years ago
FileInfo.php
3 years ago
FileList.php
3 years ago
Listing.php
2 years ago
Parts.php
3 years ago
PrepareJob.php
2 years ago
Restore.php
2 years ago
ScheduleList.php
2 years ago
Status.php
3 years ago
Upload.php
2 years ago
PrepareJob.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPStaging\Backup\Ajax; |
| 4 | |
| 5 | use WPStaging\Framework\Adapter\Directory; |
| 6 | use WPStaging\Framework\Filesystem\Filesystem; |
| 7 | use WPStaging\Framework\Security\Auth; |
| 8 | use WPStaging\Backup\BackupProcessLock; |
| 9 | |
| 10 | abstract class PrepareJob |
| 11 | { |
| 12 | protected $auth; |
| 13 | protected $filesystem; |
| 14 | protected $directory; |
| 15 | protected $processLock; |
| 16 | |
| 17 | public function __construct(Filesystem $filesystem, Directory $directory, Auth $auth, BackupProcessLock $processLock) |
| 18 | { |
| 19 | $this->directory = $directory; |
| 20 | $this->filesystem = $filesystem; |
| 21 | $this->auth = $auth; |
| 22 | $this->processLock = $processLock; |
| 23 | } |
| 24 | |
| 25 | abstract public function prepare($data = null); |
| 26 | |
| 27 | abstract public function ajaxPrepare($data); |
| 28 | |
| 29 | protected function clearCacheFolder() |
| 30 | { |
| 31 | $this->filesystem->setExcludePaths(['*.*', '!*.cache.php', '!*.cache', '!*.wpstg']); |
| 32 | $this->filesystem->delete($this->directory->getCacheDirectory(), $deleteSelf = false); |
| 33 | $this->filesystem->setExcludePaths([]); |
| 34 | $this->filesystem->mkdir($this->directory->getCacheDirectory(), true); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * @param mixed $value A value that we want to detect if it's true or false. |
| 39 | * |
| 40 | * @return bool A PHP boolean interpretation of this value. |
| 41 | */ |
| 42 | protected function jsBoolean($value) |
| 43 | { |
| 44 | return $value === 'true' || $value === true; |
| 45 | } |
| 46 | } |
| 47 |