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).

class JobState

Same name in this branch
  1. 8.x-1.x src/Plugin/views/filter/JobState.php \Drupal\tmgmt\Plugin\views\filter\JobState
  2. 8.x-1.x src/Plugin/views/field/JobState.php \Drupal\tmgmt\Plugin\views\field\JobState

Field handler which shows the state icons for jobs.

Plugin annotation

@ViewsField("tmgmt_job_state");

Hierarchy

  • class \Drupal\tmgmt\Plugin\views\field\JobState extends \Drupal\views\Plugin\views\field\NumericField

Expanded class hierarchy of JobState

File

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

Namespace

Drupal\tmgmt\Plugin\views\field
View source
class JobState extends NumericField {

  /**
   * {@inheritdoc}
   */
  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,
      ];
    }
  }

}

Members