Exemplo n.º 1
0
 /**
  * Adds a single transition to the state machine setup for a given event.
  *
  * @param TransitionInterface $transition
  * @param string $event_name If the event name is omitted, then the transition will act as sequential.
  *
  * @return StateMachineBuilderInterface
  */
 public function addTransition(TransitionInterface $transition, $event_name = '')
 {
     $transition_key = $event_name ?: StateMachine::SEQ_TRANSITIONS_KEY;
     foreach ($transition->getIncomingStateNames() as $state_name) {
         $this->allocateTransitionKey($state_name, $transition_key);
         if (in_array($transition, $this->transitions[$state_name][$transition_key], true)) {
             throw new VerificationError('Adding the same transition instance twice is not supported.');
         }
         $this->transitions[$state_name][$transition_key][] = $transition;
     }
     return $this;
 }