Error message

  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1075 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1079 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1075 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1079 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1075 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1079 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1075 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1079 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1075 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1079 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1075 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Notice: Undefined property: stdClass::$preferred in _api_make_match_link() (line 1079 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).

public function JobState::render

File

src/Plugin/views/field/JobState.php, line 19

Class

JobState
Field handler which shows the state icons for jobs.

Namespace

Drupal\tmgmt\Plugin\views\field

Code

public function render(ResultRow $values) {

  /** @var \Drupal\tmgmt\JobInterface $job */
  $job = $this
    ->getEntity($values);
  switch ($job
    ->getState()) {
    case JobInterface::STATE_UNPROCESSED:
      $label = t('Unprocessed');
      $icon = \Drupal::service('extension.list.module')
        ->getPath('tmgmt') . '/icons/rejected.svg';
      break;
    case JobInterface::STATE_ACTIVE:
      $highest_weight_icon = NULL;
      foreach ($job
        ->getItems() as $item) {
        $job_item_icon = $item
          ->getStateIcon();
        if ($job_item_icon && (!$highest_weight_icon || $highest_weight_icon['#weight'] < $job_item_icon['#weight'])) {
          $highest_weight_icon = $job_item_icon;
        }
      }
      if ($highest_weight_icon) {
        return $highest_weight_icon;
      }
      $label = t('In progress');
      $icon = \Drupal::service('extension.list.module')
        ->getPath('tmgmt') . '/icons/hourglass.svg';
      break;
    case JobInterface::STATE_CONTINUOUS:
      $label = t('Continuous');
      $icon = \Drupal::service('extension.list.module')
        ->getPath('tmgmt') . '/icons/continuous.svg';
      break;
    case JobInterface::STATE_CONTINUOUS_INACTIVE:
      $label = t('Continuous Inactive');
      $icon = \Drupal::service('extension.list.module')
        ->getPath('tmgmt') . '/icons/continuous_inactive.svg';
      break;
    default:
      $icon = NULL;
      $label = NULL;
  }
  if ($icon && $label) {
    return [
      '#theme' => 'image',
      '#uri' => \Drupal::service('file_url_generator')
        ->generateAbsoluteString($icon),
      '#title' => $label,
      '#alt' => $label,
      '#width' => 16,
      '#height' => 16,
    ];
  }
}