public function StatisticsBase::preRender in Translation Management Tool 8
Prefetch statistics for all jobs.
Overrides FieldPluginBase::preRender
File
- src/
Plugin/ views/ field/ StatisticsBase.php, line 17
Class
- StatisticsBase
- Base class for tmgmt fields.
Namespace
Drupal\tmgmt\Plugin\views\fieldCode
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);
}
}