You are here

public function DeployManager::uncompressContent in Default Content Deploy 8

Uncompressed an archive with content files.

Parameters

$file:

Return value

$this

Throws

\Exception

File

src/DeployManager.php, line 186

Class

DeployManager

Namespace

Drupal\default_content_deploy

Code

public function uncompressContent($file) {
  $folder = $this->fileSystem
    ->getTempDirectory() . '/dcd';
  $content_folder = $folder . '/content';

  // Remove old folder.
  $this->fileSystem
    ->deleteRecursive($content_folder);
  $archive = new ArchiveTar($file, 'gz');
  $list = $archive
    ->listContent();

  // Checking the folder structure.
  if (!stripos($list[0]['filename'], 'content/')) {
    $archive
      ->extract($folder);
  }
  else {
    throw new \Exception('The wrong folder structure');
  }
  return $this;
}