You are here

public function LingotekEntityController::update in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::update()
  2. 4.0.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::update()
  3. 3.0.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::update()
  4. 3.1.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::update()
  5. 3.2.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::update()
  6. 3.3.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::update()
  7. 3.4.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::update()
  8. 3.5.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::update()
  9. 3.6.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::update()
  10. 3.7.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::update()
  11. 3.8.x src/Controller/LingotekEntityController.php \Drupal\lingotek\Controller\LingotekEntityController::update()
1 string reference to 'LingotekEntityController::update'
lingotek.routing.yml in ./lingotek.routing.yml
lingotek.routing.yml

File

src/Controller/LingotekEntityController.php, line 99

Class

LingotekEntityController

Namespace

Drupal\lingotek\Controller

Code

public function update($doc_id) {

  /** @var \Drupal\lingotek\LingotekContentTranslationServiceInterface $translation_service */
  $translation_service = \Drupal::service('lingotek.content_translation');
  $entity = $translation_service
    ->loadByDocumentId($doc_id);
  try {
    if ($translation_service
      ->updateDocument($entity)) {
      drupal_set_message(t('@entity_type %title has been updated.', [
        '@entity_type' => ucfirst($entity
          ->getEntityTypeId()),
        '%title' => $entity
          ->label(),
      ]));
    }
  } catch (LingotekApiException $exception) {
    $translation_service
      ->setSourceStatus($entity, Lingotek::STATUS_ERROR);
    drupal_set_message(t('The update for @entity_type %title failed. Please try again.', array(
      '@entity_type' => $entity
        ->getEntityTypeId(),
      '%title' => $entity
        ->label(),
    )), 'error');
  }
  return $this
    ->translationsPageRedirect($entity);
}