You are here

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

Return a new file based on the one passed in.

Has the last part of the file extension removed.

For example: xxx.mysql.gz would become xxx.mysql.

Parameters

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

Return value

\Drupal\backup_migrate\Core\File\BackupFileWritableInterface A new writable backup file with the last extension removed and all of the metadata from the previous file.

Overrides TempFileManagerInterface::popExt

File

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

Class

TempFileManager
@package Drupal\backup_migrate\Core\Services

Namespace

Drupal\backup_migrate\Core\File

Code

public function popExt(BackupFileInterface $file) {

  // Pop the last extension from the last of the file.
  $parts = $file
    ->getExtList();
  array_pop($parts);
  $new_ext = implode('.', $parts);

  // Create a new temp file with the new extension.
  $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;
}