class LingotekPhase in Lingotek Translation 7.7
Same name and namespace in other branches
- 7.2 lib/Drupal/lingotek/LingotekPhase.php \LingotekPhase
- 7.3 lib/Drupal/lingotek/LingotekPhase.php \LingotekPhase
- 7.4 lib/Drupal/lingotek/LingotekPhase.php \LingotekPhase
- 7.5 lib/Drupal/lingotek/LingotekPhase.php \LingotekPhase
- 7.6 lib/Drupal/lingotek/LingotekPhase.php \LingotekPhase
A class representing a Lingotek Workflow Phase.
Hierarchy
- class \LingotekPhase
Expanded class hierarchy of LingotekPhase
2 string references to 'LingotekPhase'
- LingotekDocument::hasPhasesToComplete in lib/
Drupal/ lingotek/ LingotekDocument.php - Determines whether or not the document has Translation Targets in a complete-eligible phase.
- lingotek_mark_phases_complete in ./
lingotek.page.inc - Form constructor for the lingotek_mark_phases_complete form.
File
- lib/
Drupal/ lingotek/ LingotekPhase.php, line 11 - Defines LingotekPhase.
View source
class LingotekPhase {
/**
* The phase data
*
* @var int
*/
protected $phase;
/**
* Constructor.
*
* @param object $phase
* Phase data as returned by a getPhase API call.
*/
public function __construct($phase) {
$this->phase = $phase;
}
/**
* Injects reference to an API object.
*
* @param LingotekApi $api
* An instantiated Lingotek API object.
*/
public function setApi(LingotekApi $api) {
$this->api = $api;
}
/**
* Factory method for getting a loaded LingotekPhase object.
*
* @param int $phase_id
* A phase ID.
*
* @return LingotekPhase
* A loaded LingotekPhase object.
*/
public static function load($phase_id) {
$api = LingotekApi::instance();
$api_phase = $api
->get_phase($phase_id);
$phase = new LingotekPhase($api_phase);
$phase
->setApi($api);
return $phase;
}
/**
* 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;
}
/**
* Determines whether or not the current phase is eligible to be marked as complete.
*
* @return bool
* TRUE if the phase can be marked as complete. FALSE otherwise.
*/
public function canBeMarkedComplete() {
$result = FALSE;
// These phase types need to be at 100% complete in order to
// be eligible for mark as complete.
$needs_100_complete_phase_types = array(
'TRANSLATION',
'REVIEW',
);
if (in_array($this->phase->type, $needs_100_complete_phase_types)) {
if ($this->phase->percentComplete == 100 && !$this->phase->isMarkedComplete) {
$result = TRUE;
}
}
elseif (!$this->phase->isMarkedComplete) {
// All other phase types should be able to be marked as complete regardless
// of completion percentage.
$result = TRUE;
}
return $result;
}
/**
* Magic get for phase property access.
*/
public function __get($property) {
$value = NULL;
if (!empty($this->phase->{$property})) {
$value = $this->phase->{$property};
}
return $value;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LingotekPhase:: |
protected | property | The phase data | |
LingotekPhase:: |
public | function | Determines whether or not the current phase is eligible to be marked as complete. | |
LingotekPhase:: |
public static | function | Factory method for getting a loaded LingotekPhase object. | |
LingotekPhase:: |
public static | function | Factory method for getting a loaded LingotekPhase object. | |
LingotekPhase:: |
public | function | Injects reference to an API object. | |
LingotekPhase:: |
public | function | Constructor. | |
LingotekPhase:: |
public | function | Magic get for phase property access. |