public function LingotekTargetStatus::preRender in Lingotek Translation 4.0.x
Same name and namespace in other branches
- 8.2 src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::preRender()
- 3.0.x src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::preRender()
- 3.1.x src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::preRender()
- 3.2.x src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::preRender()
- 3.3.x src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::preRender()
- 3.4.x src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::preRender()
- 3.5.x src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::preRender()
- 3.6.x src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::preRender()
- 3.7.x src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::preRender()
- 3.8.x src/Element/LingotekTargetStatus.php \Drupal\lingotek\Element\LingotekTargetStatus::preRender()
Calculates the url and status title and adds them to the render array.
Parameters
array $element: The element as a render array.
Return value
array The element as a render array.
File
- src/
Element/ LingotekTargetStatus.php, line 48
Class
- LingotekTargetStatus
- Provides a Lingotek target status element.
Namespace
Drupal\lingotek\ElementCode
public function preRender(array $element) {
$isSourceLanguage = $element['#entity']
->language()
->getId() === $element['#language'];
if ($isSourceLanguage) {
return [];
}
if (NULL === ConfigurableLanguage::load($element['#language'])) {
return [];
}
$element['#url'] = $this
->getTargetActionUrl($element['#entity'], $element['#status'], $element['#language']);
$hasTranslation = $element['#entity']
->hasTranslation($element['#language']);
$element['#new_window'] = !($hasTranslation && $element['#status'] == Lingotek::STATUS_REQUEST) && in_array($element['#status'], [
Lingotek::STATUS_CURRENT,
Lingotek::STATUS_INTERMEDIATE,
Lingotek::STATUS_EDITED,
]);
$element['#status_text'] = $this
->getTargetStatusText($element['#status'], $element['#language'], $hasTranslation);
$element['#actions'] = $this
->getSecondaryTargetActionUrls($element['#entity'], $element['#status'], $element['#language']);
return $element;
}