public function JobItem::recalculateStatistics in Translation Management Tool 8
Recalculate statistical word-data: pending, translated, reviewed, accepted.
Overrides JobItemInterface::recalculateStatistics
1 call to JobItem::recalculateStatistics()
- JobItem::preSave in src/
Entity/ JobItem.php - Acts on an entity before the presave hook is invoked.
File
- src/
Entity/ JobItem.php, line 1001
Class
- JobItem
- Entity class for the tmgmt_job_item entity.
Namespace
Drupal\tmgmt\EntityCode
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
->count($this->unserializedData);
}
}