Recalculates statistical word-data: pending, completed, rejected, closed.
Overrides LocalTaskItemInterface::recalculateStatistics
public function recalculateStatistics() {
// Set translatable data from the current entity to calculate words.
$this
->decodeData();
if (empty($this->unserializedData)) {
$this->unserializedData = $this
->getJobItem()
->getData();
}
// Consider everything accepted when the job item is accepted.
if ($this
->isCompleted() || $this
->isClosed()) {
$this
->set('count_translated', 0);
$this
->set('count_completed', count(array_filter(\Drupal::service('tmgmt.data')
->flatten($this->unserializedData), array(
\Drupal::service('tmgmt.data'),
'filterData',
))));
$this
->set('count_untranslated', 0);
}
else {
// Reset counter values.
$this
->set('count_translated', 0);
$this
->set('count_completed', 0);
$this
->set('word_count', 0);
$this
->set('count_untranslated', count(array_filter(\Drupal::service('tmgmt.data')
->flatten($this->unserializedData), array(
\Drupal::service('tmgmt.data'),
'filterData',
))));
$this
->count($this->unserializedData);
}
}