protected function LingotekTargetTrait::getSecondaryTargetActionUrls in Lingotek Translation 3.7.x
Same name and namespace in other branches
- 4.0.x src/Element/LingotekTargetTrait.php \Drupal\lingotek\Element\LingotekTargetTrait::getSecondaryTargetActionUrls()
- 3.6.x src/Element/LingotekTargetTrait.php \Drupal\lingotek\Element\LingotekTargetTrait::getSecondaryTargetActionUrls()
- 3.8.x src/Element/LingotekTargetTrait.php \Drupal\lingotek\Element\LingotekTargetTrait::getSecondaryTargetActionUrls()
Get secondary target actions, which will be shown when expanded.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.
string $target_status: The target status.
string $langcode: The language code.
Return value
array Array of links.
2 calls to LingotekTargetTrait::getSecondaryTargetActionUrls()
- LingotekTargetStatus::preRender in src/
Element/ LingotekTargetStatus.php - Calculates the url and status title and adds them to the render array.
- LingotekTargetStatuses::getTranslationsStatuses in src/
Element/ LingotekTargetStatuses.php - Gets the translation status of an entity in a format ready to display.
File
- src/
Element/ LingotekTargetTrait.php, line 93
Class
- LingotekTargetTrait
- Trait for lingotek_target_status and lingotek_target_statuses reuse.
Namespace
Drupal\lingotek\ElementCode
protected function getSecondaryTargetActionUrls(ContentEntityInterface &$entity, $target_status, $langcode) {
$url = NULL;
$document_id = \Drupal::service('lingotek.content_translation')
->getDocumentId($entity);
$locale = \Drupal::service('lingotek.language_locale_mapper')
->getLocaleForLangcode($langcode);
$langcode_upper = strtoupper($langcode);
$actions = [];
if ($document_id) {
if (in_array($target_status, [
Lingotek::STATUS_REQUEST,
Lingotek::STATUS_DELETED,
])) {
$actions[] = [
'title' => $this
->t('Request translation'),
'url' => Url::fromRoute('lingotek.entity.request_translation', [
'doc_id' => $document_id,
'locale' => $locale,
], [
'query' => $this
->getDestinationWithQueryArray(),
]),
];
}
if ($target_status == Lingotek::STATUS_PENDING) {
$actions[] = [
'title' => $this
->t('Check translation status'),
'url' => Url::fromRoute('lingotek.entity.check_target', [
'doc_id' => $document_id,
'locale' => $locale,
], [
'query' => $this
->getDestinationWithQueryArray(),
]),
'new_window' => FALSE,
];
$actions[] = [
'title' => $this
->t('Open in Lingotek Workbench'),
'url' => Url::fromRoute('lingotek.workbench', [
'doc_id' => $document_id,
'locale' => $locale,
]),
'new_window' => TRUE,
];
}
if ($target_status == Lingotek::STATUS_READY) {
$actions[] = [
'title' => $this
->t('Download translation'),
'url' => Url::fromRoute('lingotek.entity.download', [
'doc_id' => $document_id,
'locale' => $locale,
], [
'query' => $this
->getDestinationWithQueryArray(),
]),
'new_window' => FALSE,
];
$actions[] = [
'title' => $this
->t('Open in Lingotek Workbench'),
'url' => Url::fromRoute('lingotek.workbench', [
'doc_id' => $document_id,
'locale' => $locale,
]),
'new_window' => TRUE,
];
// TODO add url for disassociate.
}
if ($target_status == Lingotek::STATUS_ERROR) {
$actions[] = [
'title' => $this
->t('Retry request'),
'url' => Url::fromRoute('lingotek.entity.request_translation', [
'doc_id' => $document_id,
'locale' => $locale,
], [
'query' => $this
->getDestinationWithQueryArray(),
]),
'new_window' => FALSE,
];
$actions[] = [
'title' => $this
->t('Retry download'),
'url' => Url::fromRoute('lingotek.entity.download', [
'doc_id' => $document_id,
'locale' => $locale,
], [
'query' => $this
->getDestinationWithQueryArray(),
]),
'new_window' => FALSE,
];
}
if ($target_status == Lingotek::STATUS_CURRENT) {
if ($entity
->hasLinkTemplate('canonical') && $entity
->hasTranslation($langcode)) {
$actions[] = [
'title' => $this
->t('View translation'),
'url' => $entity
->getTranslation($langcode)
->toUrl(),
'new_window' => FALSE,
];
}
$actions[] = [
'title' => $this
->t('Open in Lingotek Workbench'),
'url' => Url::fromRoute('lingotek.workbench', [
'doc_id' => $document_id,
'locale' => $locale,
]),
'new_window' => TRUE,
];
}
if ($target_status == Lingotek::STATUS_INTERMEDIATE) {
if ($entity
->hasLinkTemplate('canonical') && $entity
->hasTranslation($langcode)) {
$actions[] = [
'title' => $this
->t('View translation'),
'url' => $entity
->getTranslation($langcode)
->toUrl(),
'new_window' => FALSE,
];
}
$actions[] = [
'title' => $this
->t('Open in Lingotek Workbench'),
'url' => Url::fromRoute('lingotek.workbench', [
'doc_id' => $document_id,
'locale' => $locale,
]),
'new_window' => TRUE,
];
}
if ($target_status == Lingotek::STATUS_EDITED) {
if ($entity
->hasLinkTemplate('canonical') && $entity
->hasTranslation($langcode)) {
$actions[] = [
'title' => $this
->t('View translation'),
'url' => $entity
->getTranslation($langcode)
->toUrl(),
'new_window' => FALSE,
];
}
$actions[] = [
'title' => $this
->t('Open in Lingotek Workbench'),
'url' => Url::fromRoute('lingotek.workbench', [
'doc_id' => $document_id,
'locale' => $locale,
]),
'new_window' => TRUE,
];
}
}
if (in_array($target_status, [
Lingotek::STATUS_UNTRACKED,
Lingotek::STATUS_ARCHIVED,
])) {
if ($entity
->hasLinkTemplate('canonical') && $entity
->hasTranslation($langcode)) {
$actions[] = [
'title' => $this
->t('View translation'),
'url' => $entity
->getTranslation($langcode)
->toUrl(),
'new_window' => FALSE,
];
}
if ($document_id) {
$actions[] = [
'title' => $this
->t('Request translation'),
'url' => Url::fromRoute('lingotek.entity.request_translation', [
'doc_id' => $document_id,
'locale' => $locale,
], [
'query' => $this
->getDestinationWithQueryArray(),
]),
'new_window' => FALSE,
];
}
}
return $actions;
}