public function Workflow::createTransition in Workflow 7.2
Creates a Transition for this workflow.
Overrides WorkflowInterface::createTransition
1 call to Workflow::createTransition()
- Workflow::rebuildInternals in includes/
Entity/ Workflow.php - Rebuild internals that get saved separately.
File
- includes/
Entity/ Workflow.php, line 514 - Contains workflow\includes\Entity\Workflow. Contains workflow\includes\Entity\WorkflowController.
Class
Code
public function createTransition($sid, $target_sid, $values = array()) {
$workflow = $this;
if (is_numeric($sid) && is_numeric($target_sid)) {
$values['sid'] = $sid;
$values['target_sid'] = $target_sid;
}
else {
$state = $workflow
->getState($sid);
$target_state = $workflow
->getState($target_sid);
$values['sid'] = $state->sid;
$values['target_sid'] = $target_state->sid;
}
// First check if this transition already exists.
if ($transitions = entity_load('WorkflowConfigTransition', FALSE, $values)) {
$transition = reset($transitions);
}
else {
$values['wid'] = $workflow->wid;
$transition = entity_create('WorkflowConfigTransition', $values);
$transition
->save();
}
$transition
->setWorkflow($this);
// Maintain the new object in the workflow.
$this->transitions[$transition->tid] = $transition;
return $transition;
}