public function LingotekEntityController::download in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::download()
- 4.0.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::download()
- 3.0.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::download()
- 3.1.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::download()
- 3.2.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::download()
- 3.3.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::download()
- 3.4.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::download()
- 3.5.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::download()
- 3.6.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::download()
- 3.7.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::download()
- 3.8.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::download()
1 string reference to 'LingotekEntityController::download'
File
- src/
Controller/ LingotekEntityController.php, line 114
Class
Namespace
Drupal\lingotek\ControllerCode
public function download($doc_id, $locale) {
/** @var \Drupal\lingotek\LingotekContentTranslationServiceInterface $translation_service */
$translation_service = \Drupal::service('lingotek.content_translation');
$entity = $translation_service
->loadByDocumentId($doc_id);
if (!$entity) {
// TODO: log warning
return $this
->translationsPageRedirect($entity);
}
try {
if ($translation_service
->downloadDocument($entity, $locale)) {
drupal_set_message(t('The translation of @entity_type %title into @locale has been downloaded.', array(
'@entity_type' => $entity
->getEntityTypeId(),
'%title' => $entity
->label(),
'@locale' => $locale,
)));
}
else {
drupal_set_message(t('The translation of @entity_type %title into @locale failed to download.', array(
'@entity_type' => $entity
->getEntityTypeId(),
'%title' => $entity
->label(),
'@locale' => $locale,
)), 'error');
}
} catch (LingotekApiException $exception) {
drupal_set_message(t('The download for @entity_type failed. Please try again.', array(
'@entity_type' => $entity
->getEntityTypeId(),
'%title' => $entity
->label(),
)), 'error');
} catch (LingotekContentEntityStorageException $storage_exception) {
drupal_set_message(t('The download for @entity_type %title failed because of the length of one field translation value: %table.', array(
'@entity_type' => $entity
->getEntityTypeId(),
'%title' => $entity
->label(),
'%table' => $storage_exception
->getTable(),
)), 'error');
}
return $this
->translationsPageRedirect($entity);
}