You are here

protected function LingotekManagementForm::getSourceStatus in Lingotek Translation 8

Gets the source status of an entity in a format ready to display.

Parameters

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

Return value

array A render array.

1 call to LingotekManagementForm::getSourceStatus()
LingotekManagementForm::buildForm in src/Form/LingotekManagementForm.php
Form constructor.

File

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

Class

LingotekManagementForm
Form for bulk management of content.

Namespace

Drupal\lingotek\Form

Code

protected function getSourceStatus(ContentEntityInterface $entity) {
  $language_source = LingotekLocale::convertLingotek2Drupal($this->translationService
    ->getSourceLocale($entity));
  $source_status = $this->translationService
    ->getSourceStatus($entity);
  $data = array(
    'data' => array(
      '#type' => 'inline_template',
      '#template' => '<span class="language-icon source-{{status}}" title="{{status_title}}">{% if url %}<a href="{{url}}">{%endif%}{{language}}{%if url %}</a>{%endif%}</span>',
      '#context' => array(
        'language' => strtoupper($language_source),
        'status' => strtolower($source_status),
        'status_title' => $this
          ->getSourceStatusText($entity, $source_status),
        'url' => $this
          ->getSourceActionUrl($entity, $source_status),
      ),
    ),
  );
  if ($source_status == Lingotek::STATUS_EDITED && !$this->translationService
    ->getDocumentId($entity)) {
    $data['data']['#context']['status'] = strtolower(Lingotek::STATUS_REQUEST);
  }
  return $data;
}