protected function FileImport::sourceExists in Migrate Files (extended) 2.0.x
Same name and namespace in other branches
- 8 src/Plugin/migrate/process/FileImport.php \Drupal\migrate_file\Plugin\migrate\process\FileImport::sourceExists()
Check if a source exists.
1 call to FileImport::sourceExists()
- FileImport::transform in src/
Plugin/ migrate/ process/ FileImport.php - Performs the associated process.
File
- src/
Plugin/ migrate/ process/ FileImport.php, line 361
Class
- FileImport
- Imports a file from an local or external source.
Namespace
Drupal\migrate_file\Plugin\migrate\processCode
protected function sourceExists($path) {
if ($this
->isLocalUri($path)) {
return is_file($path);
}
else {
try {
$method = !empty($this->configuration['source_check_method']) ? $this->configuration['source_check_method'] : 'HEAD';
$options = !empty($this->configuration['guzzle_options']) ? $this->configuration['guzzle_options'] : [];
\Drupal::httpClient()
->request($method, $path, $options);
return TRUE;
} catch (ServerException $e) {
return FALSE;
} catch (ClientException $e) {
return FALSE;
} catch (ConnectException $e) {
return FALSE;
}
}
}