PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 4.9.2
WP STAGING – WordPress Backup, Restore, Migration & Clone v4.9.2
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 / Staging / Tasks / StagingSiteReset / ResetRequirementsCheckTask.php
wp-staging / Staging / Tasks / StagingSiteReset Last commit date
FinishStagingSiteResetTask.php 5 months ago ResetRequirementsCheckTask.php 2 weeks ago
ResetRequirementsCheckTask.php
83 lines
1 <?php
2
3 namespace WPStaging\Staging\Tasks\StagingSiteReset;
4
5 use RuntimeException;
6 use WPStaging\Core\WPStaging;
7 use WPStaging\Framework\Analytics\Actions\AnalyticsStagingReset;
8 use WPStaging\Staging\Tasks\StagingSiteUpdate\UpdateRequirementsCheckTask;
9
10 class ResetRequirementsCheckTask extends UpdateRequirementsCheckTask
11 {
12 /**
13 * @return string
14 */
15 public static function getTaskName()
16 {
17 return 'staging_site_reset_requirements_check';
18 }
19
20 /**
21 * @return string
22 */
23 public static function getTaskTitle()
24 {
25 return 'Requirements Check';
26 }
27
28 /**
29 * @return void
30 */
31 protected function logStartHeader()
32 {
33 $this->logger->info('#################### Start Staging Site Reset Job ####################');
34 }
35
36 /**
37 * @return void
38 */
39 protected function logRequirementsCheckPassed()
40 {
41 $this->logger->info('Staging Site reset requirements passed...');
42 }
43
44 /**
45 * @return void
46 */
47 protected function enqueueStartEvent()
48 {
49 WPStaging::make(AnalyticsStagingReset::class)->enqueueStartEvent($this->jobDataDto->getId(), $this->jobDataDto);
50 }
51
52 /**
53 * @return void
54 */
55 protected function enqueueRequirementFailEvent()
56 {
57 WPStaging::make(AnalyticsStagingReset::class)->enqueueFinishEvent($this->jobDataDto->getId(), $this->jobDataDto);
58 }
59
60 /**
61 * @return void
62 * @throws RuntimeException
63 */
64 protected function cannotUpdateIfStagingSiteNoExists()
65 {
66 $stagingSitePath = $this->jobDataDto->getStagingSitePath();
67 if (!is_dir($stagingSitePath)) {
68 throw new RuntimeException(esc_html__('Cannot reset staging site. Staging site directory does not exist!', 'wp-staging'));
69 }
70 }
71
72 /**
73 * @return void
74 * @throws RuntimeException
75 */
76 protected function cannotUpdateIfUsingExternalDatabase()
77 {
78 if ($this->jobDataDto->getIsExternalDatabase()) {
79 throw new RuntimeException(esc_html__('Staging site reset with external database is not supported in the basic version.', 'wp-staging'));
80 }
81 }
82 }
83