protected function ImportEntity::unzipArchive in Content Synchronizer 8.2
Same name and namespace in other branches
- 8 src/Entity/ImportEntity.php \Drupal\content_synchronizer\Entity\ImportEntity::unzipArchive()
- 3.x 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 454
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()) {
$realPathUrl = \Drupal::service('file_system')
->realpath($zipUrl);
// Get the destination dir path.
$dir = $this
->getArchiveFilesPath();
if (!is_dir($dir)) {
file_prepare_directory($dir, FILE_CREATE_DIRECTORY);
}
$archiver = new ArchiveTar($realPathUrl, 'gz');
$files = [];
foreach ($archiver
->listContent() as $file) {
$files[] = $file['filename'];
}
$archiver
->extractList($files, $dir);
}
}
}