Provides color legends for job states.
array Color legend render array.
function tmgmt_color_job_legend() {
$items = [
[
'icon' => \Drupal::service('file_url_generator')
->generateAbsoluteString(\Drupal::service('extension.list.module')
->getPath('tmgmt') . '/icons/rejected.svg'),
'legend' => t('Unprocessed'),
],
];
foreach (JobItem::getStateDefinitions() as $state_definition) {
if (!empty($state_definition['icon'])) {
$items[] = [
'icon' => \Drupal::service('file_url_generator')
->transformRelative(\Drupal::service('file_url_generator')
->generateAbsoluteString($state_definition['icon'])),
'legend' => $state_definition['label'],
];
}
}
if (\Drupal::service('tmgmt.continuous')
->hasContinuousJobs()) {
$items[] = [
'icon' => \Drupal::service('file_url_generator')
->generateAbsoluteString(\Drupal::service('extension.list.module')
->getPath('tmgmt') . '/icons/continuous.svg'),
'legend' => t('Continuous'),
];
}
$output = [
'#attached' => array(
'library' => [
'tmgmt/admin.seven',
'tmgmt/admin',
],
),
'#theme' => 'tmgmt_legend',
'#title' => t('State:'),
'#items' => $items,
'#prefix' => '<div class="tmgmt-color-legend clearfix">',
'#suffix' => '</div>',
];
return $output;
}