Sums up the counters for accepted, translated and pending items.
array $item: The current data item.
protected function count(&$item) {
if (!empty($item['#text']) || !empty($item['#file'])) {
if (\Drupal::service('tmgmt.data')
->filterDataWithFiles($item)) {
// Count words of the data item.
if (!empty($item['#text'])) {
$this->word_count->value += \Drupal::service('tmgmt.data')
->wordCount($item['#text']);
// Count HTML tags of the data item.
$this->tags_count->value += \Drupal::service('tmgmt.data')
->tagsCount($item['#text']);
}
if (isset($item['#file'])) {
$this
->get('file_count')->value++;
}
// Set default states if no state is set.
if (!isset($item['#status'])) {
// Translation is present.
if (!empty($item['#translation'])) {
$item['#status'] = TMGMT_DATA_ITEM_STATE_TRANSLATED;
}
else {
$item['#status'] = TMGMT_DATA_ITEM_STATE_PENDING;
}
}
switch ($item['#status']) {
case TMGMT_DATA_ITEM_STATE_REVIEWED:
$this->count_reviewed->value++;
break;
case TMGMT_DATA_ITEM_STATE_TRANSLATED:
$this->count_translated->value++;
break;
default:
$this->count_pending->value++;
break;
}
}
}
elseif (is_array($item)) {
foreach (Element::children($item) as $key) {
$this
->count($item[$key]);
}
}
}