Builds the translation status render array with source and job item status.
int $status: The source status: original, missing, current or outofdate.
\Drupal\tmgmt\JobItemInterface|NULL $job_item: The existing job item for the source.
array The render array for displaying the status.
function buildTranslationStatus($status, JobItemInterface $job_item = NULL) {
switch ($status) {
case 'original':
$label = t('Original language');
$icon = 'core/misc/icons/bebebe/house.svg';
break;
case 'missing':
$label = t('Not translated');
$icon = 'core/misc/icons/bebebe/ex.svg';
break;
case 'outofdate':
$label = t('Translation Outdated');
$icon = \Drupal::service('extension.list.module')
->getPath('tmgmt') . '/icons/outdated.svg';
break;
default:
$label = t('Translation up to date');
$icon = 'core/misc/icons/73b355/check.svg';
}
$build['source'] = [
'#theme' => 'image',
'#uri' => $icon,
'#title' => $label,
'#alt' => $label,
];
// If we have an active job item, wrap it in a link.
if ($job_item) {
$url = $job_item
->toUrl();
if ($job_item
->isActive() && $job_item
->getJob() && $job_item
->getJob()
->isUnprocessed()) {
$url = $job_item
->getJob()
->toUrl();
}
$url
->setOption('query', \Drupal::destination()
->getAsArray());
$item_icon = $job_item
->getStateIcon();
if ($item_icon) {
$item_icon['#title'] = $this
->t('Active job item: @state', [
'@state' => $item_icon['#title'],
]);
$build['job_item'] = [
'#type' => 'link',
'#url' => $url,
'#title' => $item_icon,
];
}
}
return $build;
}