/** * Gets the current workflow phase for the document. * * @param int $translation_target_id * The ID of the translation target whose current phase should be returned. * * @return mixed * A LingotekPhase object if the current phase could be found, or FALSE on failure. */ public function currentPhase($translation_target_id) { $phase = FALSE; if ($progress = $this->getProgress()) { 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; }