コード例 #1
0
 /**
  * Build the state
  *
  * @param array Map of states keyed by name for the workflow
  *
  * @return State Newly minted state
  */
 public function build(array $stateMap)
 {
     // Build each condition trigger
     foreach ($this->conditionBuilders as $conditionBuilder) {
         $this->state->addCondition($conditionBuilder->build($stateMap));
     }
     // Build each event trigger
     foreach ($this->eventTriggers as $eventTrigger) {
         if (array_key_exists($eventTrigger->getStateName(), $stateMap)) {
             $eventTrigger->setState($stateMap[$eventTrigger->getStateName()]);
             $this->state->addEventTrigger($eventTrigger);
         } else {
             throw new StateNotFoundException($eventTrigger->getStateName(), array_keys($stateMap));
         }
     }
     // Build each time limit trigger
     if (null !== $this->timeLimit) {
         if (array_key_exists($this->timeLimit->getStateName(), $stateMap)) {
             $this->timeLimit->setState($stateMap[$this->timeLimit->getStateName()]);
             $this->state->setTimeLimit($this->timeLimit);
         } else {
             throw new StateNotFoundException($this->timeLimit->getStateName(), array_keys($stateMap));
         }
     }
     // Return the complete state
     return $this->state;
 }
コード例 #2
0
 public function testGetStateName()
 {
     $limit = new TimeLimit(60, 'dummy');
     $this->assertEquals('dummy', $limit->getStateName());
 }