public function LingotekTargetStatus::preRender in Lingotek Translation 8.2
Same name and namespace in other branches
- 4.0.x 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 47
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']);
$element['#new_window'] = !($element['#entity']
->hasTranslation($element['#language']) && $element['#status'] == Lingotek::STATUS_REQUEST) && in_array($element['#status'], [
Lingotek::STATUS_CURRENT,
Lingotek::STATUS_INTERMEDIATE,
Lingotek::STATUS_EDITED,
]);
$element['#status_text'] = $this
->getTargetStatusText($element['#entity'], $element['#status'], $element['#language']);
return $element;
}