class BackupDatabaseLocalAdapter in Backup Database 8
BackupDatabaseLocalAdapter class.
Hierarchy
- class \Drupal\backup_db\Adapter\BackupDatabaseLocalAdapter implements BackupDatabaseAdapterInterface
Expanded class hierarchy of BackupDatabaseLocalAdapter
3 files declare their use of BackupDatabaseLocalAdapter
- BackupDatabaseAdapterTest.php in tests/
src/ Unit/ BackupDatabaseAdapterTest.php - Contains \Drupal\Tests\backup_db\Unit\BackupDatabaseAdapterTest
- BackupDatabaseForm.php in src/
Form/ BackupDatabaseForm.php - Contains \Drupal\backup_db\Form\BackupDatabaseForm.
- backup_db.module in ./
backup_db.module - backup_db.module
File
- src/
Adapter/ BackupDatabaseLocalAdapter.php, line 16 - Contains \Drupal\backup_db\Adapter\BackupDatabaseLocalAdapter
Namespace
Drupal\backup_db\AdapterView source
class BackupDatabaseLocalAdapter implements BackupDatabaseAdapterInterface {
/**
* @var \Drupal\backup_db\BackupDatabaseClientInterface
*/
private $client;
/**
* @param $client \Drupal\backup_db\BackupDatabaseClientInterface
*/
public function __construct(BackupDatabaseClientInterface $client) {
$this->client = $client;
}
/**
* @inherit
*/
public function export() {
$handler = $this->client
->getFileHandler();
$handler
->setupFile($this->client
->getSettings());
$file = $handler
->getFile();
$user = \Drupal::currentUser();
// Create a file entity.
$entity = entity_create('file', array(
'uri' => $file
->getFileUri(),
'uid' => $user
->id(),
'status' => FILE_STATUS_PERMANENT,
));
$entity
->save();
// Insert history entry.
if ($entity
->id()) {
backup_db_history_insert(array(
'fid' => $entity
->id(),
'name' => $file
->getFileName(),
'uri' => $file
->getFileUri(),
));
$export = $this->client
->dump();
$export
->start($file
->getFileUri());
}
else {
\Drupal::logger('backup_db')
->error('File entity could not be created.');
}
return $entity
->id();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BackupDatabaseLocalAdapter:: |
private | property | ||
BackupDatabaseLocalAdapter:: |
public | function |
@inherit Overrides BackupDatabaseAdapterInterface:: |
|
BackupDatabaseLocalAdapter:: |
public | function |