DatabaseSource.php in Backup and Migrate 8.4
File
lib/backup_migrate_core/src/Source/DatabaseSource.php
View source
<?php
namespace BackupMigrate\Core\Source;
use BackupMigrate\Core\Config\Config;
use BackupMigrate\Core\Plugin\FileProcessorInterface;
use BackupMigrate\Core\Plugin\FileProcessorTrait;
use BackupMigrate\Core\Plugin\PluginBase;
abstract class DatabaseSource extends PluginBase implements DatabaseSourceInterface, FileProcessorInterface {
use FileProcessorTrait;
public function configSchema($params = []) {
$schema = [];
if ($params['operation'] == 'initialize') {
$schema['fields']['host'] = [
'type' => 'text',
'title' => 'Hostname',
];
$schema['fields']['database'] = [
'type' => 'text',
'title' => 'Database',
];
$schema['fields']['username'] = [
'type' => 'text',
'title' => 'Username',
];
$schema['fields']['password'] = [
'type' => 'password',
'title' => 'Password',
];
$schema['fields']['port'] = [
'type' => 'number',
'min' => 1,
'max' => 65535,
'title' => 'Port',
];
}
return $schema;
}
public function configDefaults() {
return new Config([
'generator' => 'Backup and Migrate Core',
]);
}
public function getTableNames() {
try {
return $this
->_getTableNames();
} catch (\Exception $e) {
return [];
}
}
public function getTables() {
try {
return $this
->_getTables();
} catch (\Exception $e) {
return [];
}
}
protected function _getTableNames() {
$out = [];
foreach ($this
->_getTables() as $table) {
$out[$table['name']] = $table['name'];
}
return $out;
}
protected abstract function _getTables();
}