1 | <?php |
||
27 | abstract class BaseDestination implements DestinationInterface |
||
28 | { |
||
29 | /** |
||
30 | * @var BackupInterface[] |
||
31 | */ |
||
32 | protected $backups; |
||
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | public function getIterator() |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | public function get($name) |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | public function has($name) |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | public function all() |
||
81 | |||
82 | /** |
||
83 | * {@inheritdoc} |
||
84 | */ |
||
85 | public function count() |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | public function delete($name) |
||
105 | |||
106 | /** |
||
107 | * {@inheritdoc} |
||
108 | */ |
||
109 | public function push(BackupInterface $backup) |
||
136 | |||
137 | /** |
||
138 | * Get backup directory where backups will be transferred. If directory does not exists, it will be created. |
||
139 | * |
||
140 | * @param BackupInterface $backup Backup for which directory is fetched/created. |
||
141 | * @return string Path to created backup directory. |
||
142 | * |
||
143 | * @throws DestinationException |
||
144 | */ |
||
145 | protected abstract function getDirectoryForBackup(BackupInterface $backup); |
||
146 | |||
147 | /** |
||
148 | * Load backups from destination. |
||
149 | * |
||
150 | * @return BackupInterface[] |
||
151 | */ |
||
152 | protected abstract function load(); |
||
153 | |||
154 | /** |
||
155 | * Delete backup from destination. |
||
156 | * |
||
157 | * @param string $name Backup name to delete. |
||
158 | * |
||
159 | * @throws DestinationException |
||
160 | */ |
||
161 | protected abstract function doDelete($name); |
||
162 | |||
163 | /** |
||
164 | * Get all files in path. |
||
165 | * |
||
166 | * @param string $path Path to directory where files residue. |
||
167 | * @return FileInterface[] List of files in given location |
||
168 | */ |
||
169 | protected abstract function getFiles($path); |
||
170 | |||
171 | /** |
||
172 | * Push file to backup destination, or update it if exist and it is newer. |
||
173 | * |
||
174 | * @param string $backupDirectory Backup directory in backup destination where to push file. |
||
175 | * @param FileInterface $backupFile File to push to destination. |
||
176 | * |
||
177 | * @throws DestinationException |
||
178 | */ |
||
179 | protected abstract function pushFile($backupDirectory, FileInterface $backupFile); |
||
180 | |||
181 | /** |
||
182 | * Delete backup file from destination. |
||
183 | * |
||
184 | * @param string $backupDirectory Directory where backup file residue. |
||
185 | * @param FileInterface $backupFile Backup file to remove. |
||
186 | * |
||
187 | * @throws DestinationException |
||
188 | */ |
||
189 | protected abstract function removeFile($backupDirectory, FileInterface $backupFile); |
||
190 | |||
191 | /** |
||
192 | * Remove empty directories from backup destination. |
||
193 | * |
||
194 | * @param string $backupDirectory Backup directory to cleanup. |
||
195 | * |
||
196 | * @throws DestinationException |
||
197 | */ |
||
198 | protected abstract function removeEmptyDirectories($backupDirectory); |
||
199 | } |