Recalculate statistical word-data: pending, translated, reviewed, accepted.
Overrides JobItemInterface::recalculateStatistics
public function recalculateStatistics() {
// Set translatable data from the current entity to calculate words.
$this
->decodeData();
if (empty($this->unserializedData)) {
$this->unserializedData = $this
->getSourceData();
}
// Consider everything accepted when the job item is accepted.
if ($this
->isAccepted()) {
$this->count_pending = 0;
$this->count_translated = 0;
$this->count_reviewed = 0;
$this->count_accepted = count(array_filter(\Drupal::service('tmgmt.data')
->flatten($this->unserializedData), array(
\Drupal::service('tmgmt.data'),
'filterData',
)));
}
else {
// Reset counter values.
$this->count_pending = 0;
$this->count_translated = 0;
$this->count_reviewed = 0;
$this->count_accepted = 0;
$this->word_count = 0;
$this->tags_count = 0;
$this->file_count = 0;
$this
->count($this->unserializedData);
}
}