forked from FreePBX/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Backup.php
55 lines (53 loc) · 1.67 KB
/
Backup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace FreePBX\modules\Core;
use DirectoryIterator;
use SplObjectStorage;
use FilesystemIterator;
use FreePBX\modules\Backup\BackupBase;
class Backup Extends BackupBase{
public function runBackup($id,$transaction){
$files = [];
$dirs = [];
$configs = [];
foreach ($this->getClasses($id,$transaction) as $module) {
$dirs[$module->className] = $module->getDirs();
$configs[$module->className] = $module->getConfigs();
foreach ($module->getFiles() as $file ){
$this->addFile($file['basename'], $file['path'], $file['basevar'], $module->className);
}
if (method_exists($module, 'getSpecialTables')) {
$tables = $module->getSpecialTables();
if ($tables) {
$this->dumpTableIntoFile($module->className, $tables, false, false);
}
}
foreach($module->getDeps() as $dependency){
$this->addDependency($dependency);
}
}
$configs['features'] = $this->dumpFeatureCodes();
$configs['settings'] = $this->dumpAdvancedSettings();
$configs['kvstore'] = $this->dumpKVStore();
$configs['backup'] = $this->FreePBX->Core->getAll('backup_'.$id);
$this->addDirectories($dirs);
$this->addConfigs($configs);
}
public function getClasses($id,$transaction){
$classList = new DirectoryIterator(__DIR__ . '/Backup');
$classes = new SplObjectStorage();
foreach ($classList as $classItem) {
if($classItem->isDir()){
continue;
}
if($classItem->getExtension() !== 'php'){
continue;
}
if($classItem->getBasename() === 'Corebase.php'){
continue;
}
$classname = 'FreePBX\\modules\\Core\\Backup\\'.$classItem->getBasename('.php');
$classes->attach(new $classname($this->FreePBX, $id, $transaction));
}
return $classes;
}
}