protected function LingotekSourceStatus::getSecondarySourceActionUrls in Lingotek Translation 3.8.x
Same name and namespace in other branches
- 4.0.x src/Element/LingotekSourceStatus.php \Drupal\lingotek\Element\LingotekSourceStatus::getSecondarySourceActionUrls()
1 call to LingotekSourceStatus::getSecondarySourceActionUrls()
- 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 96
Class
- LingotekSourceStatus
- Provides a Lingotek source status element.
Namespace
Drupal\lingotek\ElementCode
protected function getSecondarySourceActionUrls(ContentEntityInterface &$entity, $source_status, $language) {
$actions = [];
$langcode = $language
->getId();
if ($entity
->hasLinkTemplate('canonical') && $entity
->hasTranslation($langcode)) {
$actions[] = [
'title' => $this
->t('View'),
'url' => $entity
->getTranslation($langcode)
->toUrl(),
'new_window' => FALSE,
];
}
$content_translation_service = \Drupal::service('lingotek.content_translation');
if ($source_status == Lingotek::STATUS_IMPORTING) {
$actions[] = [
'title' => $this
->t('Check upload status'),
'url' => Url::fromRoute('lingotek.entity.check_upload', [
'doc_id' => $content_translation_service
->getDocumentId($entity),
], [
'query' => $this
->getDestinationWithQueryArray(),
]),
'new_window' => FALSE,
];
}
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 = $content_translation_service
->getDocumentId($entity)) {
$actions[] = [
'title' => $this
->t('Update document'),
'url' => Url::fromRoute('lingotek.entity.update', [
'doc_id' => $doc_id,
], [
'query' => $this
->getDestinationWithQueryArray(),
]),
'new_window' => FALSE,
];
}
else {
$actions[] = [
'title' => $this
->t('Upload document'),
'url' => Url::fromRoute('lingotek.entity.upload', [
'entity_type' => $entity
->getEntityTypeId(),
'entity_id' => $entity
->id(),
], [
'query' => $this
->getDestinationWithQueryArray(),
]),
'new_window' => FALSE,
];
}
}
return $actions;
}