class StatisticsBase

Base class for tmgmt fields.

Hierarchy

  • class \Drupal\tmgmt\Plugin\views\field\StatisticsBase extends \Drupal\views\Plugin\views\field\FieldPluginBase

Expanded class hierarchy of StatisticsBase

2 files declare their use of StatisticsBase
Progress.php in translators/tmgmt_local/src/Plugin/views/field/Progress.php
WordCount.php in translators/tmgmt_local/src/Plugin/views/field/WordCount.php

File

src/Plugin/views/field/StatisticsBase.php, line 12

Namespace

Drupal\tmgmt\Plugin\views\field
View source
class StatisticsBase extends FieldPluginBase {

  /**
   * Prefetch statistics for all jobs.
   */
  public function preRender(&$values) {
    parent::preRender($values);

    // In case of jobs or tasks, pre-fetch the statistics in a single query and
    // add them to the static cache.
    if ($this
      ->getEntityType() == 'tmgmt_job') {
      $tjids = array();
      foreach ($values as $value) {

        // Skip loading data for continuous jobs.
        if ($this
          ->getEntity($value)
          ->isContinuous()) {
          continue;
        }
        $tjids[] = $this
          ->getValue($value);
      }
      tmgmt_job_statistics_load($tjids);
    }
    elseif ($this
      ->getEntityType() == 'tmgmt_task') {
      $tltids = array();
      foreach ($values as $value) {
        $tltids[] = $value->tjid;
      }
      tmgmt_local_task_statistics_load($tltids);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StatisticsBase::preRender public function Prefetch statistics for all jobs.