You are here

abstract class DestinationBase in Backup and Migrate 8.4

Class DestinationBase.

@package BackupMigrate\Core\Destination

Hierarchy

Expanded class hierarchy of DestinationBase

File

lib/backup_migrate_core/src/Destination/DestinationBase.php, line 15

Namespace

BackupMigrate\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
      ->_saveFile($file);
    $this
      ->_saveFileMetadata($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
      ->_deleteFile($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 _deleteFile($id);

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

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

  /**
   * Load the actual metadata for the file.
   *
   * @param \BackupMigrate\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. 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
DestinationBase::checkWritable public function 1
DestinationBase::deleteFile public function
DestinationBase::isRemote public function
DestinationBase::loadFileMetadata public function Load the metadata for the given file however it may be stored. Overrides ReadableDestinationInterface::loadFileMetadata
DestinationBase::saveFile public function Save a file to the destination. Overrides WritableDestinationInterface::saveFile 1
DestinationBase::supportedOps public function Get a list of supported operations and their weight. Overrides PluginBase::supportedOps
DestinationBase::_deleteFile abstract protected function Do the actual delete for a file. 1
DestinationBase::_loadFileMetadataArray abstract protected function Load the actual metadata for the file.
DestinationBase::_saveFile abstract protected function Do the actual file save. Should take care of the actual creation of a file in the destination without regard for metadata. 1
DestinationBase::_saveFileMetadata abstract protected function Do the metadata save. This function is called to save the data file AND the metadata sidecar file.
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 destination. This file item will not necessarily be readable nor will it have extended metadata loaded. Use loadForReading and loadFileMetadata to get those. 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.