You are here

class DebugDestination in Backup and Migrate 8.4

Class DebugDestination.

@package BackupMigrate\Core\Destination

Hierarchy

Expanded class hierarchy of DebugDestination

File

lib/backup_migrate_core/src/Destination/DebugDestination.php, line 14

Namespace

BackupMigrate\Core\Destination
View source
class DebugDestination extends StreamDestination implements WritableDestinationInterface {

  /**
   * {@inheritdoc}
   */
  function saveFile(BackupFileReadableInterface $file) {

    // Quick and dirty way to html format this output.
    if ($this
      ->confGet('format') == 'html') {
      print '<pre>';
    }

    // Output the metadata.
    if ($this
      ->confGet('showmeta')) {
      print "---------------------\n";
      print "Metadata: \n";
      print_r($file
        ->getMetaAll());
      print "---------------------\n";
    }

    // Output the body.
    if ($this
      ->confGet('showbody')) {
      print "---------------------\n";
      print "Body: \n";
      $max = $this
        ->confGet('maxbody');
      $chunk = min($max, 1024);
      if ($file
        ->openForRead()) {

        // Transfer file in 1024 byte chunks to save memory usage.
        while ($max > 0 && ($data = $file
          ->readBytes($chunk))) {
          print $data;
          $max -= $chunk;
        }
        $file
          ->close();
      }
      print "---------------------\n";
    }

    // Quick and dirty way to html format this output.
    if ($this
      ->confGet('format') == 'html') {
      print '</pre>';
    }
    exit;
  }

  /**
   * Get the default values for the plugin.
   *
   * @return \BackupMigrate\Core\Config\Config
   */
  public function configDefaults() {
    return new Config([
      'showmeta' => TRUE,
      'showbody' => TRUE,
      'maxbody' => 1024 * 16,
      'format' => 'text',
    ]);
  }

}

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::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
DebugDestination::configDefaults public function Get the default values for the plugin. Overrides ConfigurableTrait::configDefaults
DebugDestination::saveFile function Save a file to the destination. Overrides StreamDestination::saveFile
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
StreamDestination::checkWritable public function 1
StreamDestination::getFile public function
StreamDestination::loadFileForReading public function
StreamDestination::loadFileMetadata public function
TranslatableTrait::$translator protected property
TranslatableTrait::setTranslator public function
TranslatableTrait::t public function Translate the given string if there is a translator service available.