You are here

class DrupalBrowserUploadDestination in Backup and Migrate 8.4

Class BrowserUploadDestination.

@package BackupMigrate\Core\Destination

Hierarchy

Expanded class hierarchy of DrupalBrowserUploadDestination

File

src/Destination/DrupalBrowserUploadDestination.php, line 15

Namespace

BackupMigrate\Drupal\Destination
View 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

Namesort descending Modifiers Type Description Overrides
ConfigurableTrait::$config protected property The object's configuration object.
ConfigurableTrait::$init 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::confGet public function Get a specific value from the configuration.
ConfigurableTrait::config public function Get the configuration object for this item.
ConfigurableTrait::configDefaults public function Get the default values for the plugin. 10
ConfigurableTrait::configErrors public function Get any validation errors in the config.
ConfigurableTrait::configSchema public function Get a default (blank) schema. 10
ConfigurableTrait::setConfig public function Set the configuration for all plugins. 1
ConfigurableTrait::__construct public function 2
DrupalBrowserUploadDestination::fileExists public function Does the file with the given id (filename) exist in this destination. Overrides ReadableDestinationInterface::fileExists
DrupalBrowserUploadDestination::getFile 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::getFile
DrupalBrowserUploadDestination::loadFileForReading public function Load the file with the given ID from the destination. Overrides ReadableDestinationInterface::loadFileForReading
DrupalBrowserUploadDestination::loadFileMetadata public function Load the metadata for the given file however it may be stored. Overrides ReadableDestinationInterface::loadFileMetadata
PluginBase::opWeight public function What is the weight of the given operation for this plugin. Overrides PluginInterface::opWeight
PluginBase::supportedOps public function Get a list of supported operations and their weight. Overrides PluginInterface::supportedOps 8
PluginBase::supportsOp public function Does this plugin implement the given operation. Overrides PluginInterface::supportsOp
TranslatableTrait::$translator protected property
TranslatableTrait::setTranslator public function
TranslatableTrait::t public function Translate the given string if there is a translator service available.