You are here

public function LingotekInterfaceTranslationController::update in Lingotek Translation 4.0.x

Same name and namespace in other branches
  1. 3.2.x src/Controller/LingotekInterfaceTranslationController.php \Drupal\lingotek\Controller\LingotekInterfaceTranslationController::update()
  2. 3.3.x src/Controller/LingotekInterfaceTranslationController.php \Drupal\lingotek\Controller\LingotekInterfaceTranslationController::update()
  3. 3.4.x src/Controller/LingotekInterfaceTranslationController.php \Drupal\lingotek\Controller\LingotekInterfaceTranslationController::update()
  4. 3.5.x src/Controller/LingotekInterfaceTranslationController.php \Drupal\lingotek\Controller\LingotekInterfaceTranslationController::update()
  5. 3.6.x src/Controller/LingotekInterfaceTranslationController.php \Drupal\lingotek\Controller\LingotekInterfaceTranslationController::update()
  6. 3.7.x src/Controller/LingotekInterfaceTranslationController.php \Drupal\lingotek\Controller\LingotekInterfaceTranslationController::update()
  7. 3.8.x src/Controller/LingotekInterfaceTranslationController.php \Drupal\lingotek\Controller\LingotekInterfaceTranslationController::update()
1 call to LingotekInterfaceTranslationController::update()
LingotekInterfaceTranslationController::upload in src/Controller/LingotekInterfaceTranslationController.php
1 string reference to 'LingotekInterfaceTranslationController::update'
lingotek.routing.yml in ./lingotek.routing.yml
lingotek.routing.yml

File

src/Controller/LingotekInterfaceTranslationController.php, line 103

Class

LingotekInterfaceTranslationController

Namespace

Drupal\lingotek\Controller

Code

public function update(Request $request) {
  $component = $request->query
    ->get('component');
  if ($component) {
    try {
      if ($this->lingotekInterfaceTranslation
        ->updateDocument($component)) {
        $this
          ->messenger()
          ->addStatus($this
          ->t('%label has been updated.', [
          '%label' => $component,
        ]));
      }
    } catch (LingotekDocumentArchivedException $exception) {
      $this
        ->messenger()
        ->addWarning($this
        ->t('Document %label has been archived. Uploading again.', [
        '%label' => $component,
      ]));
      return $this
        ->upload($request);
    } catch (LingotekDocumentLockedException $exception) {
      $this
        ->messenger()
        ->addError($this
        ->t('Document %label has a new version. The document id has been updated for all future interactions. Please try again.', [
        '%label' => $component,
      ]));
    } catch (LingotekPaymentRequiredException $exception) {
      $this
        ->messenger()
        ->addError($this
        ->t('Community has been disabled. Please contact support@lingotek.com to re-enable your community.'));
    } catch (LingotekApiException $e) {
      $this
        ->messenger()
        ->addError($this
        ->t('%label update failed. Please try again.', [
        '%label' => $component,
      ]));
    }
  }
  return new RedirectResponse($request
    ->getRequestUri());
}