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 / Traits / StagingOperationDtoTrait.php
wp-staging / Staging / Traits Last commit date
StagingDatabaseDtoTrait.php 1 year ago StagingNetworkDtoTrait.php 2 months ago StagingOperationDtoTrait.php 2 weeks ago StagingSiteGetterTrait.php 2 months ago WithAdvanceStagingOptions.php 5 months ago WithDataAdjustmentTasks.php 9 months ago WithStagingDatabase.php 2 months ago WithStagingEnginePreference.php 2 weeks ago WithStagingRequirementLogs.php 2 weeks ago WithStagingSiteDto.php 1 year ago
StagingOperationDtoTrait.php
683 lines
1 <?php
2
3 namespace WPStaging\Staging\Traits;
4
5 use WPStaging\Staging\Service\StagingSetup;
6
7 /**
8 * Trait StagingOperationDtoTrait
9 * This trait is common between staging site creation, update and reset
10 */
11 trait StagingOperationDtoTrait
12 {
13 /**
14 * @var string
15 */
16 private $jobType = '';
17
18 /**
19 * Tables that starts with current site prefix
20 * @var array
21 */
22 private $includedTables = [];
23
24 /**
25 * Exluded Tables that start with current site prefix
26 * @var array
27 */
28 private $excludedTables = [];
29
30 /**
31 * Tables that do not start with current site prefix
32 * @var array
33 */
34 private $nonSiteTables = [];
35
36 /**
37 * Tables that are to be operated
38 * @var array
39 */
40 private $selectedTables = [];
41
42 /**
43 * Tables that are to be operated
44 * @var array
45 */
46 private $stagingTables = [];
47
48 /**
49 * Tables that are preserved during staging site update or reset.
50 * During cancel or failure of the job, these tables will be restored back to their original state.
51 * @var array
52 */
53 private $preserveTables = [];
54
55 /** @var bool */
56 private $allTablesExcluded = false;
57
58 /** @var array */
59 private $extraDirectories = [];
60
61 /** @var array */
62 private $excludedDirectories = [];
63
64 /** @var float */
65 private $excludeSizeGreaterThan = 8;
66
67 /** @var array */
68 private $excludeFileRules = [];
69
70 /** @var array */
71 private $excludeFolderRules = [];
72
73 /** @var array */
74 private $excludeExtensionRules = [];
75
76 /** @var string */
77 private $stagingSitePath = '';
78
79 /** @var string */
80 private $stagingSiteUrl = '';
81
82 /**
83 * Relative path to the uploads directory on the staging site.
84 * @var string
85 */
86 private $stagingSiteUploads = '';
87
88 /**
89 * @var bool
90 */
91 private $isWpConfigExcluded = false;
92
93 /**
94 * @var bool
95 */
96 private $isKeepPermalinks = false;
97
98 /**
99 * @var bool
100 */
101 private $isRootFilesExcluded = false;
102
103 /**
104 * @var bool
105 */
106 private $isWpAdminExcluded = false;
107
108 /**
109 * @var bool
110 */
111 private $isWpIncludesExcluded = false;
112
113 /**
114 * @var bool
115 */
116 private $isWpContentExcluded = false;
117
118 /**
119 * @var bool
120 */
121 private $isPluginsExcluded = false;
122
123 /**
124 * @var bool
125 */
126 private $isMuPluginsExcluded = false;
127
128 /**
129 * @var bool
130 */
131 private $isThemesExcluded = false;
132
133 /**
134 * @var bool
135 */
136 private $isUploadsExcluded = false;
137
138 /**
139 * @var bool
140 */
141 private $isRootDirectoriesExcluded = false;
142
143 /**
144 * @var bool
145 */
146 private $isExternalDatabase = false;
147
148 /**
149 * @param string $jobType
150 * @return void
151 */
152 public function setJobType(string $jobType)
153 {
154 $this->jobType = $jobType;
155 }
156
157 /**
158 * @return string
159 */
160 public function getJobType(): string
161 {
162 return $this->jobType;
163 }
164
165 /**
166 * @param array $tables
167 * @return void
168 */
169 public function setIncludedTables(array $tables)
170 {
171 $this->includedTables = $tables;
172 }
173
174 /**
175 * @return array
176 */
177 public function getIncludedTables(): array
178 {
179 return $this->includedTables;
180 }
181
182 /**
183 * @param array $tables
184 * @return void
185 */
186 public function setExcludedTables(array $tables)
187 {
188 $this->excludedTables = $tables;
189 }
190
191 /**
192 * @return array
193 */
194 public function getExcludedTables(): array
195 {
196 return $this->excludedTables;
197 }
198
199 /**
200 * @param array $tables
201 * @return void
202 */
203 public function setNonSiteTables(array $tables)
204 {
205 $this->nonSiteTables = $tables;
206 }
207
208 /**
209 * @return array
210 */
211 public function getNonSiteTables(): array
212 {
213 return $this->nonSiteTables;
214 }
215
216 /**
217 * @param array $tables
218 * @return void
219 */
220 public function setSelectedTables(array $tables)
221 {
222 $this->selectedTables = $tables;
223 }
224
225 /**
226 * @return array
227 */
228 public function getSelectedTables(): array
229 {
230 return $this->selectedTables;
231 }
232
233 /**
234 * @param array $tables
235 * @return void
236 */
237 public function setStagingTables(array $tables)
238 {
239 $this->stagingTables = $tables;
240 }
241
242 public function getStagingTables(): array
243 {
244 return $this->stagingTables;
245 }
246
247 /**
248 * @param string $srcTable
249 * @param string $destTable
250 * @return void
251 */
252 public function addStagingTable(string $srcTable, string $destTable)
253 {
254 $this->stagingTables[] = [
255 'source' => $srcTable,
256 'destination' => $destTable,
257 ];
258 }
259
260 /**
261 * @param array $tables
262 * @return void
263 */
264 public function setPreserveTables(array $tables)
265 {
266 $this->preserveTables = $tables;
267 }
268
269 public function getPreserveTables(): array
270 {
271 return $this->preserveTables;
272 }
273
274 /**
275 * @param string $destTable
276 * @param string $backupTable
277 * @return void
278 */
279 public function addPreserveTable(string $destTable, string $backupTable)
280 {
281 $this->preserveTables[] = [
282 'destination' => $destTable,
283 'backup' => $backupTable,
284 ];
285 }
286
287 /**
288 * @param bool $allTablesExcluded
289 * @return void
290 */
291 public function setAllTablesExcluded(bool $allTablesExcluded)
292 {
293 $this->allTablesExcluded = $allTablesExcluded;
294 }
295
296 /**
297 * @return bool
298 */
299 public function getAllTablesExcluded(): bool
300 {
301 return $this->allTablesExcluded;
302 }
303
304 /**
305 * @param array $extraDirectories
306 * @return void
307 */
308 public function setExtraDirectories(array $extraDirectories)
309 {
310 $this->extraDirectories = $extraDirectories;
311 }
312
313 /**
314 * @return array
315 */
316 public function getExtraDirectories(): array
317 {
318 return $this->extraDirectories;
319 }
320
321 /**
322 * @param array $excludedDirectories
323 * @return void
324 */
325 public function setExcludedDirectories(array $excludedDirectories)
326 {
327 $this->excludedDirectories = $excludedDirectories;
328 }
329
330 /**
331 * @return array
332 */
333 public function getExcludedDirectories(): array
334 {
335 return $this->excludedDirectories;
336 }
337
338 /**
339 * @param float $excludeSizeGreaterThan
340 * @return void
341 */
342 public function setExcludeSizeGreaterThan(float $excludeSizeGreaterThan)
343 {
344 $this->excludeSizeGreaterThan = $excludeSizeGreaterThan;
345 }
346
347 /**
348 * @return float
349 */
350 public function getExcludeSizeGreaterThan(): float
351 {
352 return $this->excludeSizeGreaterThan;
353 }
354
355 /**
356 * @param array $excludeFileRules
357 * @return void
358 */
359 public function setExcludeFileRules(array $excludeFileRules)
360 {
361 $this->excludeFileRules = $excludeFileRules;
362 }
363
364 /**
365 * @return array
366 */
367 public function getExcludeFileRules(): array
368 {
369 return $this->excludeFileRules;
370 }
371
372 /**
373 * @param array $excludeFolderRules
374 * @return void
375 */
376 public function setExcludeFolderRules(array $excludeFolderRules)
377 {
378 $this->excludeFolderRules = $excludeFolderRules;
379 }
380
381 /**
382 * @return array
383 */
384 public function getExcludeFolderRules(): array
385 {
386 return $this->excludeFolderRules;
387 }
388
389 /**
390 * @param array $excludeExtensionRules
391 * @return void
392 */
393 public function setExcludeExtensionRules(array $excludeExtensionRules)
394 {
395 $this->excludeExtensionRules = $excludeExtensionRules;
396 }
397
398 /**
399 * @return array
400 */
401 public function getExcludeExtensionRules(): array
402 {
403 return $this->excludeExtensionRules;
404 }
405
406 /**
407 * @param string $path
408 * @return void
409 */
410 public function setStagingSitePath(string $path)
411 {
412 $this->stagingSitePath = $path;
413 }
414
415 /**
416 * @return string
417 */
418 public function getStagingSitePath(): string
419 {
420 return $this->stagingSitePath;
421 }
422
423 /**
424 * @param string $url
425 * @return void
426 */
427 public function setStagingSiteUrl(string $url)
428 {
429 $this->stagingSiteUrl = $url;
430 }
431
432 /**
433 * @return string
434 */
435 public function getStagingSiteUrl(): string
436 {
437 return $this->stagingSiteUrl;
438 }
439
440 /**
441 * Set the relative path to the uploads directory on the staging site.
442 * @param string $path
443 * @return void
444 */
445 public function setStagingSiteUploads(string $path)
446 {
447 $this->stagingSiteUploads = $path;
448 }
449
450 /**
451 * Get the relative path to the uploads directory on the staging site.
452 * @return string
453 */
454 public function getStagingSiteUploads(): string
455 {
456 return $this->stagingSiteUploads;
457 }
458
459 /**
460 * @param bool $excluded
461 * @return void
462 */
463 public function setIsWpConfigExcluded(bool $excluded)
464 {
465 $this->isWpConfigExcluded = $excluded;
466 }
467
468 /**
469 * @return bool
470 */
471 public function getIsWpConfigExcluded(): bool
472 {
473 return $this->isWpConfigExcluded;
474 }
475
476 /**
477 * @param bool $isKeepPermalinks
478 * @return void
479 */
480 public function setIsKeepPermalinks(bool $isKeepPermalinks)
481 {
482 $this->isKeepPermalinks = $isKeepPermalinks;
483 }
484
485 /**
486 * @return bool
487 */
488 public function getIsKeepPermalinks(): bool
489 {
490 return $this->isKeepPermalinks;
491 }
492
493 /**
494 * @param bool $isRootFilesExcluded
495 * @return void
496 */
497 public function setIsRootFilesExcluded(bool $isRootFilesExcluded)
498 {
499 $this->isRootFilesExcluded = $isRootFilesExcluded;
500 }
501
502 /**
503 * @return bool
504 */
505 public function getIsRootFilesExcluded(): bool
506 {
507 return $this->isRootFilesExcluded;
508 }
509
510 /**
511 * @param bool $isWpAdminExcluded
512 * @return void
513 */
514 public function setIsWpAdminExcluded(bool $isWpAdminExcluded)
515 {
516 $this->isWpAdminExcluded = $isWpAdminExcluded;
517 }
518
519 /**
520 * @return bool
521 */
522 public function getIsWpAdminExcluded(): bool
523 {
524 return $this->isWpAdminExcluded;
525 }
526
527 /**
528 * @param bool $isWpIncludesExcluded
529 * @return void
530 */
531 public function setIsWpIncludesExcluded(bool $isWpIncludesExcluded)
532 {
533 $this->isWpIncludesExcluded = $isWpIncludesExcluded;
534 }
535
536 /**
537 * @return bool
538 */
539 public function getIsWpIncludesExcluded(): bool
540 {
541 return $this->isWpIncludesExcluded;
542 }
543
544 /**
545 * @param bool $isWpContentExcluded
546 * @return void
547 */
548 public function setIsWpContentExcluded(bool $isWpContentExcluded)
549 {
550 $this->isWpContentExcluded = $isWpContentExcluded;
551 }
552
553 /**
554 * @return bool
555 */
556 public function getIsWpContentExcluded(): bool
557 {
558 return $this->isWpContentExcluded;
559 }
560
561 /**
562 * @param bool $isPluginsExcluded
563 * @return void
564 */
565 public function setIsPluginsExcluded(bool $isPluginsExcluded)
566 {
567 $this->isPluginsExcluded = $isPluginsExcluded;
568 }
569
570 /**
571 * @return bool
572 */
573 public function getIsPluginsExcluded(): bool
574 {
575 return $this->isPluginsExcluded;
576 }
577
578 /**
579 * @param bool $isMuPluginsExcluded
580 * @return void
581 */
582 public function setIsMuPluginsExcluded(bool $isMuPluginsExcluded)
583 {
584 $this->isMuPluginsExcluded = $isMuPluginsExcluded;
585 }
586
587 /**
588 * @return bool
589 */
590 public function getIsMuPluginsExcluded(): bool
591 {
592 return $this->isMuPluginsExcluded;
593 }
594
595 /**
596 * @param bool $isThemesExcluded
597 * @return void
598 */
599 public function setIsThemesExcluded(bool $isThemesExcluded)
600 {
601 $this->isThemesExcluded = $isThemesExcluded;
602 }
603
604 /**
605 * @return bool
606 */
607 public function getIsThemesExcluded(): bool
608 {
609 return $this->isThemesExcluded;
610 }
611
612 /**
613 * @param bool $isUploadsExcluded
614 * @return void
615 */
616 public function setIsUploadsExcluded(bool $isUploadsExcluded)
617 {
618 $this->isUploadsExcluded = $isUploadsExcluded;
619 }
620
621 /**
622 * @return bool
623 */
624 public function getIsUploadsExcluded(): bool
625 {
626 return $this->isUploadsExcluded;
627 }
628
629 /**
630 * @param bool $isRootDirectoriesExcluded
631 * @return void
632 */
633 public function setIsRootDirectoriesExcluded(bool $isRootDirectoriesExcluded)
634 {
635 $this->isRootDirectoriesExcluded = $isRootDirectoriesExcluded;
636 }
637
638 /**
639 * @return bool
640 */
641 public function getIsRootDirectoriesExcluded(): bool
642 {
643 return $this->isRootDirectoriesExcluded;
644 }
645
646 /**
647 * @param bool $isExternalDatabase
648 * @return void
649 */
650 public function setIsExternalDatabase(bool $isExternalDatabase)
651 {
652 $this->isExternalDatabase = $isExternalDatabase;
653 }
654
655 /**
656 * @return bool
657 */
658 public function getIsExternalDatabase(): bool
659 {
660 return $this->isExternalDatabase;
661 }
662
663 public function getIsNewStagingSite(): bool
664 {
665 return $this->jobType === StagingSetup::JOB_NEW_STAGING_SITE;
666 }
667
668 public function getIsUpdateJob(): bool
669 {
670 return $this->jobType === StagingSetup::JOB_UPDATE;
671 }
672
673 public function getIsResetJob(): bool
674 {
675 return $this->jobType === StagingSetup::JOB_RESET;
676 }
677
678 public function getIsUpdateOrResetJob(): bool
679 {
680 return $this->getIsUpdateJob() || $this->getIsResetJob();
681 }
682 }
683