You are here

public function DefaultDBSourcePlugin::alterBackupMigrate in Backup and Migrate 5.0.x

Same name and namespace in other branches
  1. 8.4 src/Plugin/BackupMigrateSource/DefaultDBSourcePlugin.php \Drupal\backup_migrate\Plugin\BackupMigrateSource\DefaultDBSourcePlugin::alterBackupMigrate()

Alter the backup_migrate object to add the source and required services.

Parameters

\Drupal\backup_migrate\Core\Main\BackupMigrateInterface $bam: The BackupMigrate object to add plugins and services to.

string $key: The id of the source to add.

array $options: The alter options.

Return value

mixed

Overrides SourcePluginBase::alterBackupMigrate

See also

hook_backup_migrate_service_object_alter()

File

src/Plugin/BackupMigrateSource/DefaultDBSourcePlugin.php, line 50

Class

DefaultDBSourcePlugin
Defines an default database source plugin.

Namespace

Drupal\backup_migrate\Plugin\BackupMigrateSource

Code

public function alterBackupMigrate(BackupMigrateInterface $bam, $key, array $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)));
  }
}