abstract class DatabaseSource in Backup and Migrate 8.4
Class DatabaseSource.
@package BackupMigrate\Core\Source
Hierarchy
- class \BackupMigrate\Core\Plugin\PluginBase implements ConfigurableInterface, PluginInterface uses ConfigurableTrait
- class \BackupMigrate\Core\Source\DatabaseSource implements FileProcessorInterface, DatabaseSourceInterface uses FileProcessorTrait
Expanded class hierarchy of DatabaseSource
File
- lib/
backup_migrate_core/ src/ Source/ DatabaseSource.php, line 15
Namespace
BackupMigrate\Core\SourceView source
abstract class DatabaseSource extends PluginBase implements DatabaseSourceInterface, FileProcessorInterface {
use FileProcessorTrait;
/**
* Get a definition for user-configurable settings.
*
* @param array $params
*
* @return array
*/
public function configSchema($params = []) {
$schema = [];
// Init settings.
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;
}
/**
* Get the default values for the plugin.
*
* @return \BackupMigrate\Core\Config\Config
*/
public function configDefaults() {
return new Config([
'generator' => 'Backup and Migrate Core',
]);
}
/**
* Get a list of tables in this source.
*/
public function getTableNames() {
try {
return $this
->_getTableNames();
} catch (\Exception $e) {
// Todo: Log this exception.
return [];
}
}
/**
* Get an array of tables with some info. Each entry must have at least a
* 'name' key containing the table name.
*
* @return array
*/
public function getTables() {
try {
return $this
->_getTables();
} catch (\Exception $e) {
// Todo: Log this exception.
return [];
}
}
/**
* Get the list of tables from this db.
*
* @return array
*/
protected function _getTableNames() {
$out = [];
foreach ($this
->_getTables() as $table) {
$out[$table['name']] = $table['name'];
}
return $out;
}
/**
* Internal overridable function to actually generate table info.
*
* @return array
*/
protected abstract function _getTables();
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigurableTrait:: |
protected | property | The object's configuration object. | |
ConfigurableTrait:: |
protected | property | The initial configuration. These configuration options can be overriden by the config options but will not be overwritten. If the object is re-configured after construction any missing configuration options will revert to these values. | |
ConfigurableTrait:: |
public | function | Get a specific value from the configuration. | |
ConfigurableTrait:: |
public | function | Get the configuration object for this item. | |
ConfigurableTrait:: |
public | function | Get any validation errors in the config. | |
ConfigurableTrait:: |
public | function | Set the configuration for all plugins. | 1 |
ConfigurableTrait:: |
public | function | 2 | |
DatabaseSource:: |
public | function |
Get the default values for the plugin. Overrides ConfigurableTrait:: |
|
DatabaseSource:: |
public | function |
Get a definition for user-configurable settings. Overrides ConfigurableTrait:: |
|
DatabaseSource:: |
public | function |
Get a list of tables in this source. Overrides DatabaseSourceInterface:: |
|
DatabaseSource:: |
public | function |
Get an array of tables with some info. Each entry must have at least a
'name' key containing the table name. Overrides DatabaseSourceInterface:: |
|
DatabaseSource:: |
protected | function | Get the list of tables from this db. | |
DatabaseSource:: |
abstract protected | function | Internal overridable function to actually generate table info. | 1 |
FileProcessorTrait:: |
protected | property | ||
FileProcessorTrait:: |
public | function | Provide the file mime for the given file extension if known. | |
FileProcessorTrait:: |
public | function | Get the temp file manager. | |
FileProcessorTrait:: |
public | function | Inject the temp file manager. | |
PluginBase:: |
public | function |
What is the weight of the given operation for this plugin. Overrides PluginInterface:: |
|
PluginBase:: |
public | function |
Get a list of supported operations and their weight. Overrides PluginInterface:: |
8 |
PluginBase:: |
public | function |
Does this plugin implement the given operation. Overrides PluginInterface:: |
|
SourceInterface:: |
public | function | Export this source to the given temp file. This should be the main back up function for this source. | 2 |
SourceInterface:: |
public | function | Import to this source from the given backup file. This is the main restore function for this source. | 2 |
TranslatableTrait:: |
protected | property | ||
TranslatableTrait:: |
public | function | ||
TranslatableTrait:: |
public | function | Translate the given string if there is a translator service available. |