protected function ImportEntity::unzipArchive in Content Synchronizer 3.x
Same name and namespace in other branches
- 8.2 src/Entity/ImportEntity.php \Drupal\content_synchronizer\Entity\ImportEntity::unzipArchive()
- 8 src/Entity/ImportEntity.php \Drupal\content_synchronizer\Entity\ImportEntity::unzipArchive()
Unzip archive file.
2 calls to ImportEntity::unzipArchive()
- ImportEntity::getDataFromEntityTypeFile in src/
Entity/ ImportEntity.php - Return the data from the entity type data file.
- ImportEntity::getRootsEntities in src/
Entity/ ImportEntity.php - Return the entities to import list.
File
- src/
Entity/ ImportEntity.php, line 491
Class
- ImportEntity
- Defines the Import entity.
Namespace
Drupal\content_synchronizer\EntityCode
protected function unzipArchive() {
// Get file and zip file path.
if ($file = $this
->getArchive()) {
if ($zipUrl = $file
->getFileUri()) {
/** @var \Drupal\Core\File\FileSystem $fileSystem */
$fileSystem = \Drupal::service('file_system');
$realPathUrl = $fileSystem
->realpath($zipUrl);
// Get the destination dir path.
$dir = $this
->getArchiveFilesPath();
if (!is_dir($dir)) {
$fileSystem
->prepareDirectory($dir, FileSystem::CREATE_DIRECTORY);
}
$archiver = new ArchiveTar($realPathUrl, 'gz');
$files = [];
foreach ($archiver
->listContent() as $file) {
$files[] = $file['filename'];
}
$archiver
->extractList($files, $dir);
}
}
}