You are here

protected function LingotekTargetStatuses::getTargetActionUrlForUI in Lingotek Translation 3.6.x

Same name and namespace in other branches
  1. 4.0.x src/Element/LingotekTargetStatuses.php \Drupal\lingotek\Element\LingotekTargetStatuses::getTargetActionUrlForUI()
  2. 3.2.x src/Element/LingotekTargetStatuses.php \Drupal\lingotek\Element\LingotekTargetStatuses::getTargetActionUrlForUI()
  3. 3.3.x src/Element/LingotekTargetStatuses.php \Drupal\lingotek\Element\LingotekTargetStatuses::getTargetActionUrlForUI()
  4. 3.4.x src/Element/LingotekTargetStatuses.php \Drupal\lingotek\Element\LingotekTargetStatuses::getTargetActionUrlForUI()
  5. 3.5.x src/Element/LingotekTargetStatuses.php \Drupal\lingotek\Element\LingotekTargetStatuses::getTargetActionUrlForUI()
  6. 3.7.x src/Element/LingotekTargetStatuses.php \Drupal\lingotek\Element\LingotekTargetStatuses::getTargetActionUrlForUI()
  7. 3.8.x src/Element/LingotekTargetStatuses.php \Drupal\lingotek\Element\LingotekTargetStatuses::getTargetActionUrlForUI()
1 call to LingotekTargetStatuses::getTargetActionUrlForUI()
LingotekTargetStatuses::getTranslationsStatusesForUI in src/Element/LingotekTargetStatuses.php

File

src/Element/LingotekTargetStatuses.php, line 244

Class

LingotekTargetStatuses
Provides a Lingotek target status element.

Namespace

Drupal\lingotek\Element

Code

protected function getTargetActionUrlForUI($component, $target_status, $langcode) {
  $url = NULL;
  $document_id = \Drupal::service('lingotek.interface_translation')
    ->getDocumentId($component);
  $locale = \Drupal::service('lingotek.language_locale_mapper')
    ->getLocaleForLangcode($langcode);
  if ($document_id) {
    if ($target_status == Lingotek::STATUS_REQUEST) {
      $url = Url::fromRoute('lingotek.interface_translation.request_translation', [], [
        'query' => [
          'component' => $component,
          'locale' => $locale,
        ] + $this
          ->getDestinationWithQueryArray(),
      ]);
    }
    if ($target_status == Lingotek::STATUS_PENDING) {
      $url = Url::fromRoute('lingotek.interface_translation.check_translation', [], [
        'query' => [
          'component' => $component,
          'locale' => $locale,
        ] + $this
          ->getDestinationWithQueryArray(),
      ]);
    }
    if ($target_status == Lingotek::STATUS_READY || $target_status == Lingotek::STATUS_ERROR) {
      $url = Url::fromRoute('lingotek.interface_translation.download', [], [
        'query' => [
          'component' => $component,
          'locale' => $locale,
        ] + $this
          ->getDestinationWithQueryArray(),
      ]);
    }
    if ($target_status == Lingotek::STATUS_CURRENT || $target_status == Lingotek::STATUS_INTERMEDIATE || $target_status == Lingotek::STATUS_EDITED) {
      $url = Url::fromRoute('lingotek.workbench', [
        'doc_id' => $document_id,
        'locale' => $locale,
      ]);
    }
    if ($target_status == Lingotek::STATUS_UNTRACKED) {
      $url = Url::fromRoute('lingotek.interface_translation.request_translation', [], [
        'query' => [
          'component' => $component,
          'locale' => $locale,
        ] + $this
          ->getDestinationWithQueryArray(),
      ]);
    }
    if ($target_status == Lingotek::STATUS_DISABLED) {
      $url = NULL;
    }
  }
  return $url;
}