protected function ImportEntity::unzipArchive in Content Synchronizer 8
Same name and namespace in other branches
- 8.2 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 449
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()) {
$realZipUrl = \Drupal::service('file_system')
->realpath($zipUrl);
$zip = new \ZipArchive();
if ($zip
->open($realZipUrl)) {
$dir = $this
->getArchiveFilesPath();
if (!is_dir($dir)) {
file_prepare_directory($dir, FILE_CREATE_DIRECTORY);
}
$realDirPath = \Drupal::service('file_system')
->realpath($dir) . '/';
$result = $zip
->extractTo($realDirPath);
$zip
->close();
}
}
}
}