You are here

public function FileNamer::afterBackup in Backup and Migrate 5.0.x

Run on a backup. Name the backup file according to the configuration.

Parameters

\Drupal\backup_migrate\Core\File\BackupFileReadableInterface $file:

Return value

\Drupal\backup_migrate\Core\File\BackupFileReadableInterface

File

src/Core/Filter/FileNamer.php, line 97

Class

FileNamer
@package Drupal\backup_migrate\Core\Filter

Namespace

Drupal\backup_migrate\Core\Filter

Code

public function afterBackup(BackupFileReadableInterface $file) {
  if (\Drupal::moduleHandler()
    ->moduleExists('token')) {
    $token = \Drupal::token();
    $name = $token
      ->replace($this
      ->confGet('filename'));
  }
  else {
    $name = $this
      ->confGet('filename');
  }
  if ($this
    ->confGet('timestamp')) {
    $name .= '-' . date($this
      ->confGet('timestamp_format'));
  }
  $file
    ->setName($name);
  return $file;
}