function _drush_language_translations_get_absolute_path in Drush Language Commands 7
Returns an absolute path.
Parameters
string $path: Absolute or relative (to drupal root) path.
Return value
string Absolute path.
2 calls to _drush_language_translations_get_absolute_path()
- drush_language_translations_export in ./
language_translations.drush.inc - Export translations from one or more locale groups.
- drush_language_translations_import in ./
language_translations.drush.inc - Import translations to one or more locale groups.
File
- ./
language_translations.drush.inc, line 665 - Drush language commands related to translations.
Code
function _drush_language_translations_get_absolute_path($path) {
// relative path should be relative to cwd(), rather than Drupal root-dir
$drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT');
if (drush_is_absolute_path($path)) {
return $path;
}
elseif (valid_url($path, TRUE)) {
// Get name of this file.
$parsed_url = drupal_parse_url($path);
$parsed_path = explode('/', $parsed_url['path']);
$filename = end($parsed_path);
$destination = drush_find_tmp() . DIRECTORY_SEPARATOR . $filename;
// Download file content
$content = file_get_contents($path);
// Save file to unmanaged file. It will be saved to managed temporary later.
return file_unmanaged_save_data($content, $destination);
}
else {
return $drupal_root . DIRECTORY_SEPARATOR . $path;
}
}