You are here

abstract class DestinationBase in Backup and Migrate 5.0.x

@package Drupal\backup_migrate\Core\Destination

Hierarchy

Expanded class hierarchy of DestinationBase

File

src/Core/Destination/DestinationBase.php, line 15

Namespace

Drupal\backup_migrate\Core\Destination
View source
abstract class DestinationBase extends PluginBase implements ReadableDestinationInterface, WritableDestinationInterface {

  /**
   * Get a list of supported operations and their weight.
   *
   * @return array
   */
  public function supportedOps() {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function saveFile(BackupFileReadableInterface $file) {
    $this
      ->saveTheFile($file);
    $this
      ->saveTheFileMetadata($file);
  }

  /**
   * {@inheritdoc}
   */
  public function loadFileMetadata(BackupFileInterface $file) {

    // If this file is already loaded, simply return it.
    // @todo Fix this inappropriate use of file metadata.
    if (!$file
      ->getMeta('metadata_loaded')) {
      $metadata = $this
        ->loadFileMetadataArray($file);
      $file
        ->setMetaMultiple($metadata);
      $file
        ->setMeta('metadata_loaded', TRUE);
    }
    return $file;
  }

  /**
   * {@inheritdoc}
   */
  public function deleteFile($id) {
    return $this
      ->deleteTheFile($id);
  }

  /**
   * {@inheritdoc}
   */
  public function isRemote() {
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function checkWritable() {
    throw new DestinationNotWritableException('The specified destination cannot be written to.');
  }

  /**
   * Do the actual delete for a file.
   *
   * @param string $id
   *   The id of the file to delete.
   */
  protected abstract function deleteTheFile($id);

  /**
   * Do the actual file save.
   *
   * Should take care of the actual creation of a file in the destination
   * without regard for metadata.
   *
   * @param \Drupal\backup_migrate\Core\File\BackupFileReadableInterface $file
   */
  protected abstract function saveTheFile(BackupFileReadableInterface $file);

  /**
   * Do the metadata save.
   *
   * This function is called to save the data file AND the metadata sidecar
   * file.
   *
   * @param \Drupal\backup_migrate\Core\File\BackupFileInterface $file
   */
  protected abstract function saveTheFileMetadata(BackupFileInterface $file);

  /**
   * Load the actual metadata for the file.
   *
   * @param \Drupal\backup_migrate\Core\File\BackupFileInterface $file
   */
  protected abstract function loadFileMetadataArray(BackupFileInterface $file);

}

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
DestinationBase::checkWritable public function 1
DestinationBase::deleteFile public function
DestinationBase::deleteTheFile abstract protected function Do the actual delete for a file. 1
DestinationBase::isRemote public function
DestinationBase::loadFileMetadata public function Load the metadata for the given file however it may be stored. Overrides ReadableDestinationInterface::loadFileMetadata
DestinationBase::loadFileMetadataArray abstract protected function Load the actual metadata for the file.
DestinationBase::saveFile public function Save a file to the destination. Overrides WritableDestinationInterface::saveFile 1
DestinationBase::saveTheFile abstract protected function Do the actual file save. 1
DestinationBase::saveTheFileMetadata abstract protected function Do the metadata save.
DestinationBase::supportedOps public function Get a list of supported operations and their weight. Overrides PluginBase::supportedOps
PluginBase::opWeight public function What is the weight of the given operation for this plugin. Overrides PluginInterface::opWeight
PluginBase::supportsOp public function Does this plugin implement the given operation. Overrides PluginInterface::supportsOp
ReadableDestinationInterface::fileExists public function Does the file with the given id (filename) exist in this destination. 2
ReadableDestinationInterface::getFile public function Get a file object representing the file with the given ID from the dest. 2
ReadableDestinationInterface::loadFileForReading public function Load the file with the given ID from the destination. 2
TranslatableTrait::$translator protected property
TranslatableTrait::setTranslator public function
TranslatableTrait::t public function Translate the given string if there is a translator service available.