public function LingotekConfigTranslationController::download in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::download()
- 4.0.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::download()
- 3.0.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::download()
- 3.1.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::download()
- 3.2.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::download()
- 3.3.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::download()
- 3.4.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::download()
- 3.5.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::download()
- 3.6.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::download()
- 3.7.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::download()
- 3.8.x src/Controller/LingotekConfigTranslationController.php \Drupal\lingotek\Controller\LingotekConfigTranslationController::download()
1 string reference to 'LingotekConfigTranslationController::download'
File
- src/
Controller/ LingotekConfigTranslationController.php, line 411
Class
Namespace
Drupal\lingotek\ControllerCode
public function download($entity_type, $entity_id, $locale, Request $request) {
if ($entity_type === $entity_id) {
// It is not a config entity, but a config object.
$definition = $this->configMapperManager
->getDefinition($entity_type);
try {
if ($this->translationService
->downloadConfig($entity_id, $locale)) {
drupal_set_message($this
->t('Translation to %locale downloaded successfully', [
'%locale' => $locale,
]));
}
} catch (LingotekApiException $e) {
drupal_set_message($this
->t('%label @locale translation download failed. Please try again.', [
'%label' => $definition['title'],
'@locale' => $locale,
]), 'error');
}
return $this
->redirectToConfigTranslateOverview($entity_type);
}
// Check if it's a field.
if (substr($entity_type, -7) == '_fields') {
// Hack for fields, the entity is field config.
$entity_type = 'field_config';
}
$entity = $this
->entityManager()
->getStorage($entity_type)
->load($entity_id);
try {
if ($this->translationService
->downloadDocument($entity, $locale)) {
drupal_set_message($this
->t('Translation to %locale downloaded successfully', [
'%locale' => $locale,
]));
}
} catch (LingotekApiException $e) {
drupal_set_message($this
->t('%label @locale translation download failed. Please try again.', [
'%label' => $entity
->label(),
'@locale' => $locale,
]), 'error');
}
return $this
->redirectToEntityTranslateOverview($entity_type, $entity_id);
}