private function ResponsiveFaviconsAdmin::archiveExtract in Responsive Favicons 8
Unpacks a downloaded archive file.
Parameters
string $file: The filename of the archive you wish to extract.
string $directory: The directory you wish to extract the archive into.
Return value
\Drupal\Core\Archiver\ArchiverInterface The Archiver object used to extract the archive.
Throws
\Exception
1 call to ResponsiveFaviconsAdmin::archiveExtract()
- ResponsiveFaviconsAdmin::submitForm in src/
Form/ ResponsiveFaviconsAdmin.php - Form submission handler.
File
- src/
Form/ ResponsiveFaviconsAdmin.php, line 311
Class
- ResponsiveFaviconsAdmin
- Class ResponsiveFaviconsAdmin.
Namespace
Drupal\responsive_favicons\FormCode
private function archiveExtract($file, $directory) {
$archiver = \Drupal::service('plugin.manager.archiver')
->getInstance([
'filepath' => $file,
]);
if (!$archiver) {
throw new \Exception($this
->t('Cannot extract %file, not a valid archive.', [
'%file' => $file,
]));
}
if (file_exists($directory)) {
$this->fileSystem
->deleteRecursive($directory);
}
$archiver
->extract($directory);
return $archiver;
}