コード例 #1
0
 /**
  * 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;
     }
 }
コード例 #2
0
 /**
  * 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;
     }
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 public function testName()
 {
     $this->assertEquals('test-state', (string) $this->state->getName());
 }
コード例 #5
0
 /**
  * Sets the WorkflowState of this internship.
  *
  * @param WorkflowState $state
  */
 public function setState(WorkflowState $state)
 {
     $this->state = $state->getName();
 }
コード例 #6
0
ファイル: Workflow.php プロジェクト: dpaduch/Workflow
 /**
  * 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;
 }