class DBExcludeFilter in Backup and Migrate 5.0.x
Allows the exclusion of certain data from a database.
@package Drupal\backup_migrate\Core\Filter
Hierarchy
- class \Drupal\backup_migrate\Core\Plugin\PluginBase implements ConfigurableInterface, PluginInterface uses ConfigurableTrait
- class \Drupal\backup_migrate\Core\Filter\DBExcludeFilter
Expanded class hierarchy of DBExcludeFilter
1 file declares its use of DBExcludeFilter
- DefaultDBSourcePlugin.php in src/
Plugin/ BackupMigrateSource/ DefaultDBSourcePlugin.php
File
- src/
Core/ Filter/ DBExcludeFilter.php, line 15
Namespace
Drupal\backup_migrate\Core\FilterView source
class DBExcludeFilter extends PluginBase {
/**
* @var \Drupal\backup_migrate\Core\Plugin\PluginManager
*/
protected $sourceManager;
/**
* The 'beforeDbTableBackup' plugin op.
*
* @param array $table
* @param array $params
*
* @return array $table
*/
public function beforeDbTableBackup(array $table, array $params = []) {
$exclude = $this
->confGet('exclude_tables');
$nodata = $this
->confGet('nodata_tables');
if (in_array($table['name'], $exclude)) {
$table['exclude'] = TRUE;
}
if (in_array($table['name'], $nodata)) {
$table['nodata'] = TRUE;
}
return $table;
}
/**
* Get the default values for the plugin.
*
* @return \Drupal\backup_migrate\Core\Config\Config
*/
public function configDefaults() {
return new Config([
'source' => '',
'exclude_tables' => [],
'nodata_tables' => [],
]);
}
/**
* Get a definition for user-configurable settings.
*
* @param array $params
*
* @return array
*/
public function configSchema(array $params = []) {
$schema = [];
if ($params['operation'] == 'backup') {
$tables = [];
foreach ($this
->sources()
->getAll() as $source_key => $source) {
if ($source instanceof DatabaseSourceInterface) {
$tables += $source
->getTableNames();
}
if ($tables) {
// Backup settings.
$schema['groups']['default'] = [
'title' => $this
->t('Exclude database tables'),
];
$table_select = [
'type' => 'enum',
'multiple' => TRUE,
'options' => $tables,
'actions' => [
'backup',
],
'group' => 'default',
];
$schema['fields']['exclude_tables'] = $table_select + [
'title' => $this
->t('Exclude these tables entirely'),
];
$schema['fields']['nodata_tables'] = $table_select + [
'title' => $this
->t('Exclude data from these tables'),
];
}
}
}
return $schema;
}
/**
* @return \Drupal\backup_migrate\Core\Plugin\PluginManager
*/
public function sources() {
return $this->sourceManager ? $this->sourceManager : new PluginManager();
}
/**
* @param \Drupal\backup_migrate\Core\Plugin\PluginManager $sourceManager
*/
public function setSourceManager(PluginManager $sourceManager) {
$this->sourceManager = $sourceManager;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigurableTrait:: |
protected | property | The object's configuration object. | |
ConfigurableTrait:: |
protected | property | The initial configuration. | |
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 | |
DBExcludeFilter:: |
protected | property | ||
DBExcludeFilter:: |
public | function | The 'beforeDbTableBackup' plugin op. | |
DBExcludeFilter:: |
public | function |
Get the default values for the plugin. Overrides ConfigurableTrait:: |
|
DBExcludeFilter:: |
public | function |
Get a definition for user-configurable settings. Overrides ConfigurableTrait:: |
|
DBExcludeFilter:: |
public | function | ||
DBExcludeFilter:: |
public | function | ||
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:: |
|
TranslatableTrait:: |
protected | property | ||
TranslatableTrait:: |
public | function | ||
TranslatableTrait:: |
public | function | Translate the given string if there is a translator service available. |