public function GeolocationGeometryDataBase::download in Geolocation Field 8.3
Download batch callback.
Return value
string Batch return.
File
- modules/
geolocation_geometry/ modules/ geolocation_geometry_data/ src/ GeolocationGeometryDataBase.php, line 77
Class
- GeolocationGeometryDataBase
- Class GeolocationGeometryDataBase.
Namespace
Drupal\geolocation_geometry_dataCode
public function download() {
$destination = \Drupal::service('file_system')
->getTempDirectory() . '/' . $this->sourceFilename;
if (!is_file($destination)) {
$client = \Drupal::httpClient();
$client
->get($this->sourceUri, [
'save_to' => $destination,
]);
}
if (!empty($this->localDirectory) && substr(strtolower($this->sourceFilename), -3) === 'zip') {
$zip = new \ZipArchive();
$res = $zip
->open($destination);
if ($res === TRUE) {
$zip
->extractTo(\Drupal::service('file_system')
->getTempDirectory() . '/' . $this->localDirectory);
$zip
->close();
}
else {
return t('ERROR downloading @url', [
'@url' => $this->sourceUri,
]);
}
}
return t('Successfully downloaded @url', [
'@url' => $this->sourceUri,
]);
}