/** * NB: All of the params are optional for compatibility with db->getObjects() .. Database is done wrong. Don't have time to fix it. * @param Internship $i * @param PHPWS_User $phpwsUser * @param int $timestamp * @param WorkflowState $fromState * @param WorkflowState $toState */ public function __construct(Internship $i = null, PHPWS_User $phpwsUser = null, $timestamp = null, WorkflowState $fromState = null, WorkflowState $toState = null, $note = null) { if (!is_null($i)) { $this->id = 0; $this->internship_id = $i->getId(); $this->username = $phpwsUser->getUsername(); $this->timestamp = $timestamp; $this->from_state = $fromState->getName(); $this->to_state = $toState->getName(); $this->note = $note; } }
/** * NB: All of the params are optional for compatibility with db->getObjects() .. Database is done wrong. Don't have time to fix it. * @param Internship $i * @param PHPWS_User $phpwsUser * @param int $timestamp * @param WorkflowState $fromState * @param WorkflowState $toState */ public function __construct(Internship $i = null, \PHPWS_User $phpwsUser = null, $timestamp = null, WorkflowState $fromState = null, WorkflowState $toState = null, $note = null) { if (!is_null($i)) { $this->id = 0; $this->internship_id = $i->getId(); $this->username = $phpwsUser->getUsername(); $this->timestamp = $timestamp; // Strip namespace from start of from and to states, all four backspaces are required to escaping backslash $this->from_state = preg_replace("/Intern\\\\WorkflowState\\\\/", '', $fromState->getName()); $this->to_state = preg_replace("/Intern\\\\WorkflowState\\\\/", '', $toState->getName()); $this->note = $note; } }
public static function getTransitionsFromState(WorkflowState $state, Internship $i) { $stateName = $state->getName(); $transitions = self::getAllTransitions(); $outgoingTrans = array(); foreach ($transitions as $t) { // Set the actual source state $t->setSourceState($state); if (is_array($t->getSourceState()) && in_array($stateName, $t->getSourceState()) && $t->isApplicable($i)) { $outgoingTrans[] = $t; } else { if (($t->getSourceState() == $stateName || $t->getSourceState() == '*') && $t->isApplicable($i)) { $outgoingTrans[] = $t; } } } uasort($outgoingTrans, array('self', 'sortTransitions')); return $outgoingTrans; }
public function testName() { $this->assertEquals('test-state', (string) $this->state->getName()); }
/** * Sets the WorkflowState of this internship. * * @param WorkflowState $state */ public function setState(WorkflowState $state) { $this->state = $state->getName(); }
/** * Adds new workflow state. * * @param WorkflowState $state State object to add * * @return \DevelArts\Workflow\Workflow */ public function addState(WorkflowState $state) { $this->states[$state->getName()] = $state; return $this; }