You are here

public function LingotekDocument::currentPhase in Lingotek Translation 7.3

Same name and namespace in other branches
  1. 7.7 lib/Drupal/lingotek/LingotekDocument.php \LingotekDocument::currentPhase()
  2. 7.2 lib/Drupal/lingotek/LingotekDocument.php \LingotekDocument::currentPhase()
  3. 7.4 lib/Drupal/lingotek/LingotekDocument.php \LingotekDocument::currentPhase()
  4. 7.5 lib/Drupal/lingotek/LingotekDocument.php \LingotekDocument::currentPhase()
  5. 7.6 lib/Drupal/lingotek/LingotekDocument.php \LingotekDocument::currentPhase()

Gets the current workflow phase for the document.

Parameters

int $translation_target_id: The ID of the translation target whose current phase should be returned.

Return value

mixed A LingotekPhase object if the current phase could be found, or FALSE on failure.

1 call to LingotekDocument::currentPhase()
LingotekDocument::hasPhasesToComplete in lib/Drupal/lingotek/LingotekDocument.php
Determines whether or not the document has Translation Targets in a complete-eligible phase.

File

lib/Drupal/lingotek/LingotekDocument.php, line 71
Defines LingotekDocument.

Class

LingotekDocument
A class representing a Lingotek Document

Code

public function currentPhase($translation_target_id) {
  $phase = FALSE;
  if ($progress = $this
    ->translationProgress()) {
    foreach ($progress->translationTargets as $target) {
      if ($target->id == $translation_target_id && !empty($target->phases)) {
        $current_phase = FALSE;
        foreach ($target->phases as $phase) {
          if (!$phase->isMarkedComplete) {
            $current_phase = $phase;
            break;
          }
        }

        // Return either the first uncompleted phase, or the last phase if all phases are complete.
        $current_phase = $current_phase ? $current_phase : end($target->phases);
        $phase = LingotekPhase::loadWithData($current_phase);
        break;
      }
    }
  }
  return $phase;
}