You are here

protected function LingotekManagementForm::getSourceActionUrl in Lingotek Translation 8

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity:

String $source_status:

Return value

\Drupal\Core\Url

1 call to LingotekManagementForm::getSourceActionUrl()
LingotekManagementForm::getSourceStatus in src/Form/LingotekManagementForm.php
Gets the source status of an entity in a format ready to display.

File

src/Form/LingotekManagementForm.php, line 1211
Contains \Drupal\Lingotek\Form\LingotekManagementForm.

Class

LingotekManagementForm
Form for bulk management of content.

Namespace

Drupal\lingotek\Form

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' => $this->translationService
        ->getDocumentId($entity),
    ], [
      'query' => $this
        ->getDestinationWithQueryArray(),
    ]);
  }
  if ($source_status == Lingotek::STATUS_EDITED || $source_status == Lingotek::STATUS_UNTRACKED || $source_status == Lingotek::STATUS_ERROR) {
    if ($doc_id = $this->translationService
      ->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;
}