class StreamDestination in Backup and Migrate 8.4
Class StreamDestination.
@package BackupMigrate\Core\Destination
Hierarchy
- class \BackupMigrate\Core\Plugin\PluginBase implements ConfigurableInterface, PluginInterface uses ConfigurableTrait
- class \BackupMigrate\Core\Destination\StreamDestination implements ConfigurableInterface, WritableDestinationInterface
Expanded class hierarchy of StreamDestination
File
- lib/
backup_migrate_core/ src/ Destination/ StreamDestination.php, line 16
Namespace
BackupMigrate\Core\DestinationView source
class StreamDestination extends PluginBase implements WritableDestinationInterface, ConfigurableInterface {
/**
* {@inheritdoc}
*/
function saveFile(BackupFileReadableInterface $file) {
$stream_uri = $this
->confGet('streamuri');
if ($fp_out = fopen($stream_uri, 'w')) {
$file
->openForRead();
while ($data = $file
->readBytes(1024 * 512)) {
fwrite($fp_out, $data);
}
fclose($fp_out);
$file
->close();
}
else {
throw new \Exception("Cannot open the file {$stream_uri} for writing");
}
}
/**
* {@inheritdoc}
*/
public function checkWritable() {
$stream_uri = $this
->confGet('streamuri');
// The stream must exist.
if (!file_exists($stream_uri)) {
throw new DestinationNotWritableException('The file stream !uri does not exist.', [
'%uri' => $stream_uri,
]);
}
// The stream must be writable.
if (!file_exists($stream_uri)) {
throw new DestinationNotWritableException('The file stream !uri cannot be written to.', [
'%uri' => $stream_uri,
]);
}
}
/**
* {@inheritdoc}
*/
public function getFile($id) {
return NULL;
}
/**
* {@inheritdoc}
*/
public function loadFileMetadata(BackupFileInterface $file) {
return $file;
}
/**
* {@inheritdoc}
*/
public function loadFileForReading(BackupFileInterface $file) {
return $file;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigurableTrait:: |
protected | property | The object's configuration object. | |
ConfigurableTrait:: |
protected | property | The initial configuration. These configuration options can be overriden by the config options but will not be overwritten. If the object is re-configured after construction any missing configuration options will revert to these values. | |
ConfigurableTrait:: |
public | function | Get a specific value from the configuration. | |
ConfigurableTrait:: |
public | function | Get the configuration object for this item. | |
ConfigurableTrait:: |
public | function | Get the default values for the plugin. | 10 |
ConfigurableTrait:: |
public | function | Get any validation errors in the config. | |
ConfigurableTrait:: |
public | function | Get a default (blank) schema. | 10 |
ConfigurableTrait:: |
public | function | Set the configuration for all plugins. | 1 |
ConfigurableTrait:: |
public | function | 2 | |
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:: |
|
StreamDestination:: |
public | function | 1 | |
StreamDestination:: |
public | function | ||
StreamDestination:: |
public | function | ||
StreamDestination:: |
public | function | ||
StreamDestination:: |
function |
Save a file to the destination. Overrides WritableDestinationInterface:: |
2 | |
TranslatableTrait:: |
protected | property | ||
TranslatableTrait:: |
public | function | ||
TranslatableTrait:: |
public | function | Translate the given string if there is a translator service available. |