You are here

protected function LingotekSourceStatus::getSourceActionUrl in Lingotek Translation 4.0.x

Same name and namespace in other branches
  1. 8.2 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 71

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 (in_array($source_status, [
    Lingotek::STATUS_EDITED,
    Lingotek::STATUS_UNTRACKED,
    Lingotek::STATUS_ERROR,
    Lingotek::STATUS_CANCELLED,
    Lingotek::STATUS_ARCHIVED,
    Lingotek::STATUS_DELETED,
  ])) {
    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;
}