You are here

public function TMGMTLocalTaskItemController::save in Translation Management Tool 7

@todo Eliminate the need to flatten and unflatten the TaskItem data.

Overrides EntityAPIController::save

File

translators/tmgmt_local/controller/tmgmt_local.controller.task_item.inc, line 20
Contains the task item controller.

Class

TMGMTLocalTaskItemController
Controller class for the local task entity.

Code

public function save($entity, DatabaseTransaction $transaction = NULL) {

  // Consider everything translated when the job item is translated.
  if ($entity
    ->isCompleted()) {
    $entity->count_untranslated = 0;
    $entity->count_translated = count(tmgmt_flatten_data($entity->data));
    $entity->count_completed = 0;
  }
  elseif ($entity
    ->isClosed()) {
    $entity->count_untranslated = 0;
    $entity->count_translated = 0;
    $entity->count_completed = count(tmgmt_flatten_data($entity->data));
  }
  else {

    // Start with assuming that all data is untranslated, then go through it
    // and count translated data.
    $entity->count_untranslated = count(array_filter(tmgmt_flatten_data($entity
      ->getJobItem()
      ->getData()), '_tmgmt_filter_data'));
    $entity->count_translated = 0;
    $entity->count_completed = 0;
    $this
      ->count($entity->data, $entity);
  }
  return parent::save($entity, $transaction);
}