PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 3.3.1
WP STAGING – WordPress Backup, Restore, Migration & Clone v3.3.1
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 / Dto / Traits / RemoteUploadTrait.php
wp-staging / Backup / Dto / Traits Last commit date
DateCreatedTrait.php 3 years ago IsExcludingTrait.php 2 years ago IsExportingTrait.php 2 years ago RemoteUploadTrait.php 2 years ago WithPluginsThemesMuPluginsTrait.php 3 years ago
RemoteUploadTrait.php
225 lines
1 <?php
2
3 namespace WPStaging\Backup\Dto\Traits;
4
5 /**
6 * Used for Remote Upload
7 */
8 trait RemoteUploadTrait
9 {
10 /** @var bool */
11 private $isAutomatedBackup = false;
12
13 /** @var int The size of all backup multipart files or single full backup file */
14 private $totalBackupSize = 0;
15
16 /** @var array */
17 private $filesToUpload = [];
18
19 /** @var array */
20 private $uploadedFiles = [];
21
22 /** @var array Selected storages for backup. */
23 private $storages;
24
25 /**
26 * @var array The meta data used by Remote Storages to help uploading.
27 * Stores ResumeURI for Google Drive
28 * Stores UploadId and UploadedParts Meta for Amazon S3
29 */
30 private $remoteStorageMeta;
31
32 /**
33 * True for stand alone upload job action.
34 * Always false when creating backups no matter if the backup is uploaded after that or not.
35 * @var bool
36 */
37 private $isOnlyUpload = false;
38
39 /**
40 * @return bool
41 */
42 public function getIsAutomatedBackup(): bool
43 {
44 return $this->isAutomatedBackup;
45 }
46
47 /**
48 * Hydrated dynamically.
49 *
50 * @param bool $isAutomatedBackup
51 * @return void
52 */
53 public function setIsAutomatedBackup(bool $isAutomatedBackup)
54 {
55 $this->isAutomatedBackup = $isAutomatedBackup;
56 }
57
58 /**
59 * @return int
60 */
61 public function getTotalBackupSize(): int
62 {
63 return $this->totalBackupSize;
64 }
65
66 /**
67 * @param int $totalBackupSize
68 * @return void
69 */
70 public function setTotalBackupSize(int $totalBackupSize)
71 {
72 $this->totalBackupSize = $totalBackupSize;
73 }
74
75 /**
76 * @return array
77 */
78 public function getFilesToUpload(): array
79 {
80 return $this->filesToUpload;
81 }
82
83 /**
84 * @param array $filesToUpload
85 * @return void
86 */
87 public function setFilesToUpload(array $filesToUpload = [])
88 {
89 $this->filesToUpload = $filesToUpload;
90 }
91
92 /**
93 * @return array
94 */
95 public function getUploadedFiles(): array
96 {
97 return $this->uploadedFiles;
98 }
99
100 /**
101 * @param array $uploadedFiles
102 * @return void
103 */
104 public function setUploadedFiles(array $uploadedFiles = [])
105 {
106 $this->uploadedFiles = $uploadedFiles;
107 }
108
109 /**
110 * @param string $uploadedFile
111 * @param int $fileSize
112 * @param string $fileHash
113 * @return void
114 */
115 public function setUploadedFile(string $uploadedFile, int $fileSize, string $fileHash = '')
116 {
117 $this->uploadedFiles[$uploadedFile] = [
118 'size' => $fileSize,
119 'hash' => $fileHash,
120 ];
121 }
122
123 /**
124 * @return bool
125 */
126 public function getIsOnlyUpload(): bool
127 {
128 return $this->isOnlyUpload;
129 }
130
131 /**
132 * @param bool isOnlyUpload
133 * @return void
134 */
135 public function setIsOnlyUpload(bool $isOnlyUpload)
136 {
137 $this->isOnlyUpload = $isOnlyUpload;
138 }
139
140 /**
141 * @return array
142 */
143 public function getStorages(): array
144 {
145 return $this->storages;
146 }
147
148 /**
149 * @param array|string $storages
150 */
151 public function setStorages($storages = [])
152 {
153 if (!is_array($storages)) {
154 $storages = json_decode($storages, true);
155 }
156
157 $this->storages = $storages;
158 }
159
160 /**
161 * @return array
162 */
163 public function getRemoteStorageMeta()
164 {
165 return $this->remoteStorageMeta;
166 }
167
168 /**
169 * @param array $remoteStorageMeta
170 * @return void
171 */
172 public function setRemoteStorageMeta($remoteStorageMeta = [])
173 {
174 $this->remoteStorageMeta = $remoteStorageMeta;
175 }
176
177 /** @return bool */
178 public function isLocalBackup(): bool
179 {
180 return in_array('localStorage', $this->getStorages());
181 }
182
183 /** @return bool */
184 public function isUploadToGoogleDrive(): bool
185 {
186 return in_array('googleDrive', $this->getStorages());
187 }
188
189 /** @return bool */
190 public function isUploadToAmazonS3(): bool
191 {
192 return in_array('amazonS3', $this->getStorages());
193 }
194
195 /** @return bool */
196 public function isUploadToSftp(): bool
197 {
198 return in_array('sftp', $this->getStorages());
199 }
200
201 /** @return bool */
202 public function isUploadToWasabi(): bool
203 {
204 return in_array('wasabi-s3', $this->getStorages());
205 }
206
207 /** @return bool */
208 public function isUploadToDigitalOceanSpaces(): bool
209 {
210 return in_array('digitalocean-spaces', $this->getStorages());
211 }
212
213 /** @return bool */
214 public function isUploadToGenericS3(): bool
215 {
216 return in_array('generic-s3', $this->getStorages());
217 }
218
219 /** @return bool */
220 public function isUploadToDropbox(): bool
221 {
222 return in_array('dropbox', $this->getStorages());
223 }
224 }
225