You are here

protected function LingotekSourceStatus::getSourceActionUrl in Lingotek Translation 8.2

Same name and namespace in other branches
  1. 4.0.x src/Element/LingotekSourceStatus.php \Drupal\lingotek\Element\LingotekSourceStatus::getSourceActionUrl()
  2. 3.0.x src/Element/LingotekSourceStatus.php \Drupal\lingotek\Element\LingotekSourceStatus::getSourceActionUrl()
  3. 3.1.x src/Element/LingotekSourceStatus.php \Drupal\lingotek\Element\LingotekSourceStatus::getSourceActionUrl()
  4. 3.2.x src/Element/LingotekSourceStatus.php \Drupal\lingotek\Element\LingotekSourceStatus::getSourceActionUrl()
  5. 3.3.x src/Element/LingotekSourceStatus.php \Drupal\lingotek\Element\LingotekSourceStatus::getSourceActionUrl()
  6. 3.4.x src/Element/LingotekSourceStatus.php \Drupal\lingotek\Element\LingotekSourceStatus::getSourceActionUrl()
  7. 3.5.x src/Element/LingotekSourceStatus.php \Drupal\lingotek\Element\LingotekSourceStatus::getSourceActionUrl()
  8. 3.6.x src/Element/LingotekSourceStatus.php \Drupal\lingotek\Element\LingotekSourceStatus::getSourceActionUrl()
  9. 3.7.x src/Element/LingotekSourceStatus.php \Drupal\lingotek\Element\LingotekSourceStatus::getSourceActionUrl()
  10. 3.8.x src/Element/LingotekSourceStatus.php \Drupal\lingotek\Element\LingotekSourceStatus::getSourceActionUrl()

Get the source action url based on the source status.

Parameters

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

string $source_status: The source status.

Return value

\Drupal\Core\Url An url object.

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

File

src/Element/LingotekSourceStatus.php, line 63

Class

LingotekSourceStatus
Provides a Lingotek source status element.

Namespace

Drupal\lingotek\Element

Code

protected function getSourceActionUrl(ContentEntityInterface &$entity, $source_status) {
  $url = NULL;
  if ($source_status == Lingotek::STATUS_IMPORTING) {
    $url = Url::fromRoute('lingotek.entity.check_upload', [
      'doc_id' => \Drupal::service('lingotek.content_translation')
        ->getDocumentId($entity),
    ], [
      'query' => $this
        ->getDestinationWithQueryArray(),
    ]);
  }
  if ($source_status == Lingotek::STATUS_EDITED || $source_status == Lingotek::STATUS_UNTRACKED || $source_status == Lingotek::STATUS_ERROR || $source_status == Lingotek::STATUS_CANCELLED) {
    if ($doc_id = \Drupal::service('lingotek.content_translation')
      ->getDocumentId($entity)) {
      $url = Url::fromRoute('lingotek.entity.update', [
        'doc_id' => $doc_id,
      ], [
        'query' => $this
          ->getDestinationWithQueryArray(),
      ]);
    }
    else {
      $url = Url::fromRoute('lingotek.entity.upload', [
        'entity_type' => $entity
          ->getEntityTypeId(),
        'entity_id' => $entity
          ->id(),
      ], [
        'query' => $this
          ->getDestinationWithQueryArray(),
      ]);
    }
  }
  return $url;
}