You are here

public function TempFileManager::pushExt in Backup and Migrate 8.4

Return a new file based on the passed in file with the given file extension. This should maintain the metadata of the file passed in with the new file extension added after the old one. For example: xxx.mysql would become xxx.mysql.gz.

Parameters

\BackupMigrate\Core\File\BackupFileInterface $file: The file to add the extension to.

$ext: The new file extension.

Return value

\BackupMigrate\Core\File\BackupFileWritableInterface A new writable backup file with the new extension and all of the metadata from the previous file.

Overrides TempFileManagerInterface::pushExt

File

lib/backup_migrate_core/src/File/TempFileManager.php, line 56

Class

TempFileManager
Class TempFileManager.

Namespace

BackupMigrate\Core\File

Code

public function pushExt(BackupFileInterface $file, $ext) {

  // Push the new extension on to the new file.
  $parts = $file
    ->getExtList();
  array_push($parts, $ext);
  $new_ext = implode('.', $parts);

  // Copy the file metadata to a new TempFile.
  $out = new WritableStreamBackupFile($this->adapter
    ->createTempFile($new_ext));

  // Copy the file metadata to a new TempFile.
  $out
    ->setMetaMultiple($file
    ->getMetaAll());
  $out
    ->setName($file
    ->getName());
  $out
    ->setExtList($parts);
  return $out;
}