Workflow state model.
More...
List of all members.
Detailed Description
Workflow state model.
- Copyright:
- 2011-2012 Perforce Software. All rights reserved
- License:
- Please see LICENSE.txt in top-level folder of this distribution.
- Version:
- 2012.2/486814
Member Function Documentation
Workflow_Model_State::getLabel |
( |
| ) |
|
Get the current label.
- Returns:
- string the current label or id if label is empty or not a string.
{
$label = $this->_getValue('label');
return is_string($label) && strlen($label) ? $label : (string) $this->getId();
}
Workflow_Model_State::getTransition |
( |
$ |
name | ) |
|
Get specified transition.
- Parameters:
-
string | $name | transition name. |
- Returns:
- array field details for the named transition.
- Exceptions:
-
{
$transitions = $this->getTransitions();
if (!array_key_exists($name, $transitions)) {
throw new Workflow_Exception(
"Transition '$name' not found among the transitions for this state."
);
}
return is_array($transitions[$name]) ? $transitions[$name] : array();
}
Workflow_Model_State::getTransitionModel |
( |
$ |
name | ) |
|
Get specified transition from this state as model.
- Parameters:
-
string | $name | transition name. |
- Returns:
- Workflow_Model_Transition state transition model.
Workflow_Model_State::getTransitionModels |
( |
| ) |
|
Get the transitions attached to this state as models.
- Returns:
- P4Cms_Model_Iterator transitions of this state.
Workflow_Model_State::getTransitions |
( |
| ) |
|
Get list of transitions attached to this state.
- Returns:
- array the list of transitions (transitions definitions).
{
$transitions = $this->_getValue('transitions');
$transitions = is_array($transitions) ? $transitions : array();
return array_intersect_key(
$transitions,
$this->getWorkflow()->getStates()
);
}
Workflow_Model_State::getValidTransitionsFor |
( |
P4Cms_Record $ |
record, |
|
|
array $ |
pending = null |
|
) |
| |
Get the transitions that are valid for the given record (as determined by transition conditions).
There is the option of passing an array of pending values to consider when evaluating conditions. These would typically come from a request as the user makes changes to the record.
- Parameters:
-
P4Cms_Record | $record | the record to evaulate for context. |
array | null | $pending | optional - updated values to consider. |
- Returns:
- P4Cms_Model_Iterator a list of allowed transitions for this record.
{
$transitions = new P4Cms_Model_Iterator;
foreach ($this->getTransitionModels() as $transition) {
if ($transition->areConditionsMetFor($record, $pending)) {
$transitions[] = $transition;
}
}
return $transitions;
}
Workflow_Model_State::getWorkflow |
( |
| ) |
|
Get the workflow that this state belongs to.
- Returns:
- Workflow_Model_Workflow workflow that this state belongs to
- Exceptions:
-
Workflow_Model_State::hasTransition |
( |
$ |
name | ) |
|
Check if state has the specified transition.
- Parameters:
-
string | $name | transition name. |
- Returns:
- bool true if state defines given transition, false otherwise.
Set a workflow that is partially made up by this state.
- Parameters:
-
Member Data Documentation
Workflow_Model_State::$_fields [static, protected] |
Initial value: array(
'label' => array(
'accessor' => 'getLabel'
),
'transitions' => array(
'accessor' => 'getTransitions'
),
'workflow' => array(
'accessor' => 'getWorkflow',
'mutator' => 'setWorkflow'
)
)
Reimplemented from P4Cms_Model.
The documentation for this class was generated from the following file: