function tmgmt_color_job_legend

Provides color legends for job states.

Return value

array Color legend render array.

1 call to tmgmt_color_job_legend()
JobLegend::render in src/Plugin/views/area/JobLegend.php

File

./tmgmt.module, line 1031
Main module file for the Translation Management module.

Code

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;
}