5 * Defines LingotekPhase.
9 * A class representing a Lingotek Workflow Phase.
22 * @param object $phase
23 * Phase data as returned by a getPhase API call.
25 public
function __construct($phase) {
26 $this->phase
= $phase;
30 * Injects reference to an API object.
32 * @param LingotekApi $api
33 * An instantiated Lingotek API object.
35 public
function setApi(LingotekApi
$api) {
40 * Factory method for getting a loaded LingotekPhase object.
42 * @param int $phase_id
45 * @return LingotekPhase
46 * A loaded LingotekPhase object.
48 public static
function load($phase_id) {
49 $api = LingotekApi
::instance();
50 $api_phase = $api->get_phase($phase_id);
51 $phase = new
LingotekPhase($api_phase);
58 * Factory method for getting a loaded LingotekPhase object.
60 * @param object $api_phase
61 * Phase data as returned by a getPhase Lingotek API call.
63 * @return LingotekPhase
64 * A loaded LingotekPhase object.
66 public static
function loadWithData($api_phase) {
67 $api = LingotekApi
::instance();
68 $phase = new
LingotekPhase($api_phase);
76 * Determines whether or not the current phase is eligible to be marked as complete.
79 * TRUE if the phase can be marked as complete. FALSE otherwise.
81 public
function canBeMarkedComplete() {
84 // These phase types need to be at 100% complete in order to
85 // be eligible for mark as complete.
86 $needs_100_complete_phase_types = array(
91 if (in_array($this->phase
->type
, $needs_100_complete_phase_types)) {
92 if ($this->phase
->percentComplete
== 100 && !$this->phase
->isMarkedComplete
) {
96 elseif (!$this->phase
->isMarkedComplete
) {
97 // All other phase types should be able to be marked as complete regardless
98 // of completion percentage.
106 * Magic get for phase property access.
108 public
function __get($property) {
111 if (!empty($this->phase
->$property)) {
112 $value = $this->phase
->$property;