You are here

public function TempFileManager::pushExt in Backup and Migrate 5.0.x

Return a new file based on the passed in file with the given file ext.

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

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

$ext: The new file extension.

Return value

\Drupal\backup_migrate\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

src/Core/File/TempFileManager.php, line 61

Class

TempFileManager
@package Drupal\backup_migrate\Core\Services

Namespace

Drupal\backup_migrate\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;
}