/** * Factory method for getting a loaded LingotekPhase object. * * @param object $api_phase * Phase data as returned by a getPhase Lingotek API call. * * @return LingotekPhase * A loaded LingotekPhase object. */ public static function loadWithData($api_phase) { $api = LingotekApi::instance(); $phase = new LingotekPhase($api_phase); $phase->setApi($api); return $phase; }
/** * 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; }