public function LingotekManagementForm::uploadDocument in Lingotek Translation 8
Upload source for translation.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.
File
- src/
Form/ LingotekManagementForm.php, line 715 - Contains \Drupal\Lingotek\Form\LingotekManagementForm.
Class
- LingotekManagementForm
- Form for bulk management of content.
Namespace
Drupal\lingotek\FormCode
public function uploadDocument(ContentEntityInterface $entity, $language, &$context) {
$context['message'] = $this
->t('Uploading @type %label.', [
'@type' => $entity
->getEntityType()
->getLabel(),
'%label' => $entity
->label(),
]);
if ($profile = $this->lingotekConfiguration
->getEntityProfile($entity, FALSE)) {
try {
$this->translationService
->uploadDocument($entity);
} catch (LingotekApiException $exception) {
$this->translationService
->setSourceStatus($entity, Lingotek::STATUS_ERROR);
if ($this->translationService
->getDocumentId($entity)) {
drupal_set_message(t('The update for @entity_type %title failed. Please try again.', array(
'@entity_type' => $entity
->getEntityTypeId(),
'%title' => $entity
->label(),
)), 'error');
}
else {
drupal_set_message(t('The upload for @entity_type %title failed. Please try again.', array(
'@entity_type' => $entity
->getEntityTypeId(),
'%title' => $entity
->label(),
)), 'error');
}
}
}
else {
$bundleInfos = $this->entityManager
->getBundleInfo($entity
->getEntityTypeId());
drupal_set_message($this
->t('The @type %label has no profile assigned so it was not processed.', [
'@type' => $bundleInfos[$entity
->bundle()]['label'],
'%label' => $entity
->label(),
]), 'warning');
}
}