class DefaultDBSourcePlugin in Backup and Migrate 8.4
Same name and namespace in other branches
- 5.0.x src/Plugin/BackupMigrateSource/DefaultDBSourcePlugin.php \Drupal\backup_migrate\Plugin\BackupMigrateSource\DefaultDBSourcePlugin
Defines an default database source plugin.
Plugin annotation
@BackupMigrateSourcePlugin(
id = "DefaultDB",
title = @Translation("Default Database"),
description = @Translation("Back up the Drupal db."),
locked = true
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \BackupMigrate\Drupal\EntityPlugins\WrapperPluginBase implements WrapperPluginInterface
- class \BackupMigrate\Drupal\EntityPlugins\SourcePluginBase implements SourcePluginInterface
- class \Drupal\backup_migrate\Plugin\BackupMigrateSource\DefaultDBSourcePlugin
- class \BackupMigrate\Drupal\EntityPlugins\SourcePluginBase implements SourcePluginInterface
- class \BackupMigrate\Drupal\EntityPlugins\WrapperPluginBase implements WrapperPluginInterface
Expanded class hierarchy of DefaultDBSourcePlugin
File
- src/
Plugin/ BackupMigrateSource/ DefaultDBSourcePlugin.php, line 21
Namespace
Drupal\backup_migrate\Plugin\BackupMigrateSourceView source
class DefaultDBSourcePlugin extends SourcePluginBase {
/**
* Get the Backup and Migrate plugin object.
*
* @return BackupMigrate\Core\Plugin\PluginInterface;
*/
public function getObject() {
// Add the default database.
$info = \Drupal\Core\Database\Database::getConnectionInfo('default', 'default');
$info = $info['default'];
// Set a default port if none is set. Because that's what core does.
$info['port'] = empty($info['port']) ? 3306 : $info['port'];
if ($info['driver'] == 'mysql') {
$conf = $this
->getConfig();
foreach ($info as $key => $value) {
$conf
->set($key, $value);
}
return new DrupalMySQLiSource($conf);
}
return NULL;
}
/**
* {@inheritdoc}
*/
public function alterBackupMigrate(BackupMigrateInterface $bam, $key, $options = []) {
if ($source = $this
->getObject()) {
$bam
->sources()
->add($key, $source);
// @TODO: This needs a better solution.
$config = [
'exclude_tables' => [],
'nodata_tables' => [
'cache_advagg_minify',
'cache_bootstrap',
'cache_config',
'cache_container',
'cache_data',
'cache_default',
'cache_discovery',
'cache_discovery_migration',
'cache_dynamic_page_cache',
'cache_entity',
'cache_menu',
'cache_migrate',
'cache_page',
'cache_render',
'cache_rest',
'cache_toolbar',
'sessions',
'watchdog',
'webprofiler',
],
];
// @TODO: Allow modules to add their own excluded tables.
$bam
->plugins()
->add('db_exclude', new DBExcludeFilter(new Config($config)));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DefaultDBSourcePlugin:: |
public | function |
Alter the backup and migrate object to add the source and required services. Overrides SourcePluginBase:: |
|
DefaultDBSourcePlugin:: |
public | function |
Get the Backup and Migrate plugin object. Overrides WrapperPluginBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
WrapperPluginBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
WrapperPluginBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurablePluginInterface:: |
|
WrapperPluginBase:: |
public | function | Return a Backup and Migrate Config object with the plugin configuration. | |
WrapperPluginBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurablePluginInterface:: |
|
WrapperPluginBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurablePluginInterface:: |
|
WrapperPluginBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
1 |