MetadataWriter.php in Backup and Migrate 5.0.x
File
src/Core/Filter/MetadataWriter.php
View source
<?php
namespace Drupal\backup_migrate\Core\Filter;
use Drupal\backup_migrate\Core\Config\Config;
use Drupal\backup_migrate\Core\File\BackupFileWritableInterface;
use Drupal\backup_migrate\Core\Plugin\FileProcessorInterface;
use Drupal\backup_migrate\Core\Plugin\FileProcessorTrait;
use Drupal\backup_migrate\Core\Plugin\PluginBase;
use Drupal\backup_migrate\Core\Plugin\PluginCallerInterface;
use Drupal\backup_migrate\Core\Plugin\PluginCallerTrait;
class MetadataWriter extends PluginBase implements FileProcessorInterface, PluginCallerInterface {
use FileProcessorTrait;
use PluginCallerTrait;
public function configSchema(array $params = []) {
$schema = [];
if ($params['operation'] == 'backup') {
$schema['groups']['advanced'] = [
'title' => 'Advanced Settings',
];
$schema['fields']['description'] = [
'group' => 'advanced',
'type' => 'text',
'title' => 'Description',
'multiline' => TRUE,
];
}
return $schema;
}
public function configDefaults() {
return new Config([
'description' => '',
'generator' => 'Backup and Migrate',
'generatorversion' => defined('BACKUP_MIGRATE_CORE_VERSION') ? constant('BACKUP_MIGRATE_CORE_VERSION') : 'unknown',
'generatorurl' => 'https://github.com/backupmigrate',
'bam_sourceid' => '',
]);
}
protected function getMetaKeys() {
return [
'description',
'generator',
'generatorversion',
'generatorurl',
'bam_sourceid',
'bam_scheduleid',
];
}
public function setUp($operand, $options) {
if ($options['operation'] == 'backup' && $options['source_id']) {
$this
->config()
->set('bam_sourceid', $options['source_id']);
if ($source = $this
->plugins()
->get($options['source_id'])) {
}
}
return $operand;
}
public function afterBackup(BackupFileWritableInterface $file) {
foreach ($this
->getMetaKeys() as $key) {
$value = $this
->confGet($key);
$file
->setMeta($key, $value);
}
return $file;
}
}