You are here

protected function LingotekTargetStatus::getTargetActionUrl in Lingotek Translation 3.2.x

Same name and namespace in other branches
  1. 8.2 src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::getTargetActionUrl()
  2. 3.0.x src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::getTargetActionUrl()
  3. 3.1.x src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::getTargetActionUrl()
  4. 3.3.x src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::getTargetActionUrl()
  5. 3.4.x src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::getTargetActionUrl()
  6. 3.5.x src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::getTargetActionUrl()

Get the target action url based on the source status.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.

string $target_status: The target status.

string $langcode: The language code.

Return value

\Drupal\Core\Url An url object.

1 call to LingotekTargetStatus::getTargetActionUrl()
LingotekTargetStatus::preRender in src/Element/LingotekTargetStatus.php
Calculates the url and status title and adds them to the render array.

File

src/Element/LingotekTargetStatus.php, line 123

Class

LingotekTargetStatus
Provides a Lingotek target status element.

Namespace

Drupal\lingotek\Element

Code

protected function getTargetActionUrl(ContentEntityInterface &$entity, $target_status, $langcode) {
  $url = NULL;
  $document_id = \Drupal::service('lingotek.content_translation')
    ->getDocumentId($entity);
  $locale = \Drupal::service('lingotek.language_locale_mapper')
    ->getLocaleForLangcode($langcode);
  if ($document_id) {
    if ($target_status == Lingotek::STATUS_REQUEST) {
      $url = Url::fromRoute('lingotek.entity.request_translation', [
        'doc_id' => $document_id,
        'locale' => $locale,
      ], [
        'query' => $this
          ->getDestinationWithQueryArray(),
      ]);
    }
    if ($target_status == Lingotek::STATUS_PENDING) {
      $url = Url::fromRoute('lingotek.entity.check_target', [
        'doc_id' => $document_id,
        'locale' => $locale,
      ], [
        'query' => $this
          ->getDestinationWithQueryArray(),
      ]);
    }
    if ($target_status == Lingotek::STATUS_READY || $target_status == Lingotek::STATUS_ERROR) {
      $url = Url::fromRoute('lingotek.entity.download', [
        'doc_id' => $document_id,
        'locale' => $locale,
      ], [
        'query' => $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.entity.request_translation', [
        'doc_id' => $document_id,
        'locale' => $locale,
      ], [
        'query' => $this
          ->getDestinationWithQueryArray(),
      ]);
    }
  }
  return $url;
}