class DrupalBrowserUploadDestination in Backup and Migrate 8.4
Class BrowserUploadDestination.
@package BackupMigrate\Core\Destination
Hierarchy
- class \BackupMigrate\Core\Plugin\PluginBase implements ConfigurableInterface, PluginInterface uses ConfigurableTrait
- class \BackupMigrate\Drupal\Destination\DrupalBrowserUploadDestination implements ReadableDestinationInterface
Expanded class hierarchy of DrupalBrowserUploadDestination
File
- src/
Destination/ DrupalBrowserUploadDestination.php, line 15
Namespace
BackupMigrate\Drupal\DestinationView source
class DrupalBrowserUploadDestination extends PluginBase implements ReadableDestinationInterface {
/**
* {@inheritdoc}
*/
public function getFile($id) {
$file_upload = \Drupal::request()->files
->get("files", NULL, TRUE)[$id];
// Make sure there's an upload to process.
if (!empty($file_upload)) {
$out = new ReadableStreamBackupFile($file_upload
->getRealPath());
$out
->setFullName($file_upload
->getClientOriginalName());
return $out;
}
}
/**
* Load the metadata for the given file however it may be stored.
*
* @param \BackupMigrate\Core\File\BackupFileInterface $file
*
* @return \BackupMigrate\Core\File\BackupFileInterface
*/
public function loadFileMetadata(BackupFileInterface $file) {
return $file;
}
/**
* Load the file with the given ID from the destination.
*
* @param \BackupMigrate\Core\File\BackupFileInterface $file
*
* @return \BackupMigrate\Core\File\BackupFileReadableInterface The file if it exists or NULL if it doesn't
*/
public function loadFileForReading(BackupFileInterface $file) {
return $file;
}
/**
* Does the file with the given id (filename) exist in this destination.
*
* @param string $id The id (usually the filename) of the file.
*
* @return bool True if the file exists, false if it does not.
*/
public function fileExists($id) {
return (bool) \Drupal::request()->files
->has("files[{$id}]");
}
}
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 | |
DrupalBrowserUploadDestination:: |
public | function |
Does the file with the given id (filename) exist in this destination. Overrides ReadableDestinationInterface:: |
|
DrupalBrowserUploadDestination:: |
public | function |
Get a file object representing the file with the given ID from the destination.
This file item will not necessarily be readable nor will it have extended
metadata loaded. Use loadForReading and loadFileMetadata to get those. Overrides ReadableDestinationInterface:: |
|
DrupalBrowserUploadDestination:: |
public | function |
Load the file with the given ID from the destination. Overrides ReadableDestinationInterface:: |
|
DrupalBrowserUploadDestination:: |
public | function |
Load the metadata for the given file however it may be stored. Overrides ReadableDestinationInterface:: |
|
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:: |
|
TranslatableTrait:: |
protected | property | ||
TranslatableTrait:: |
public | function | ||
TranslatableTrait:: |
public | function | Translate the given string if there is a translator service available. |