JobCancel.php
46 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPStaging\Backup\Job\Jobs; |
| 4 | |
| 5 | use WPStaging\Backup\Job\AbstractJob; |
| 6 | use WPStaging\Backup\Task\Tasks\CleanupTmpFilesTask; |
| 7 | use WPStaging\Backup\Task\Tasks\CleanupTmpTablesTask; |
| 8 | |
| 9 | class JobCancel extends AbstractJob |
| 10 | { |
| 11 | /** @var array The array of tasks to execute for this job. Populated at init(). */ |
| 12 | private $tasks = []; |
| 13 | |
| 14 | public static function getJobName() |
| 15 | { |
| 16 | return 'backup_cancel'; |
| 17 | } |
| 18 | |
| 19 | protected function getJobTasks() |
| 20 | { |
| 21 | return $this->tasks; |
| 22 | } |
| 23 | |
| 24 | protected function execute() |
| 25 | { |
| 26 | //$this->startBenchmark(); |
| 27 | |
| 28 | try { |
| 29 | $response = $this->getResponse($this->currentTask->execute()); |
| 30 | } catch (\Exception $e) { |
| 31 | $this->currentTask->getLogger()->critical($e->getMessage()); |
| 32 | $response = $this->getResponse($this->currentTask->generateResponse(false)); |
| 33 | } |
| 34 | |
| 35 | //$this->finishBenchmark(get_class($this->currentTask)); |
| 36 | |
| 37 | return $response; |
| 38 | } |
| 39 | |
| 40 | protected function init() |
| 41 | { |
| 42 | $this->tasks[] = CleanupTmpFilesTask::class; |
| 43 | $this->tasks[] = CleanupTmpTablesTask::class; |
| 44 | } |
| 45 | } |
| 46 |