DrupalFilesSourcePlugin.php in Backup and Migrate 8.4
File
src/Plugin/BackupMigrateSource/DrupalFilesSourcePlugin.php
View source
<?php
namespace Drupal\backup_migrate\Plugin\BackupMigrateSource;
use BackupMigrate\Core\Config\Config;
use BackupMigrate\Core\Filter\FileExcludeFilter;
use BackupMigrate\Core\Main\BackupMigrateInterface;
use BackupMigrate\Core\Source\MySQLiSource;
use BackupMigrate\Drupal\EntityPlugins\SourcePluginBase;
class DrupalFilesSourcePlugin extends SourcePluginBase {
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
public function alterBackupMigrate(BackupMigrateInterface $bam, $key, $options = []) {
$source = $this
->getObject();
$bam
->sources()
->add($key, $source);
$config = [
'exclude_filepaths' => [],
'source' => $source,
];
switch ($this
->getConfig()
->get('directory')) {
case 'public://':
$config['exclude_filepaths'] = [
'js',
'css',
'php',
'styles',
'config_*',
'.htaccess',
];
break;
case 'private://':
$config['exclude_filepaths'] = [
'backup_migrate',
];
break;
}
$bam
->plugins()
->add($key . '_exclude', new FileExcludeFilter(new Config($config)));
}
}