You are here

class DrupalBrowserUploadDestination in Backup and Migrate 5.0.x

@package Drupal\backup_migrate\Core\Destination

Hierarchy

Expanded class hierarchy of DrupalBrowserUploadDestination

1 file declares its use of DrupalBrowserUploadDestination
backup_migrate.module in ./backup_migrate.module
Primary hook implementations for Backup Migrate.

File

src/Drupal/Destination/DrupalBrowserUploadDestination.php, line 15

Namespace

Drupal\backup_migrate\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 \Drupal\backup_migrate\Core\File\BackupFileInterface $file
   *
   * @return \Drupal\backup_migrate\Core\File\BackupFileInterface
   */
  public function loadFileMetadata(BackupFileInterface $file) {
    return $file;
  }

  /**
   * Load the file with the given ID from the destination.
   *
   * @param \Drupal\backup_migrate\Core\File\BackupFileInterface $file
   *
   * @return \Drupal\backup_migrate\Core\File\BackupFileReadableInterface The file if it exists or NULL if it doesn't
   */
  public function loadFileForReading(BackupFileInterface $file) {
    return $file;
  }

  /**
   * {@inheritdoc}
   */
  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.
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 dest. 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.