private function transition(TransitionalStateInterface $fromState, EventInterface $event)
    {
        if ($fromState instanceof StateActionInterface) {
            $exitEvent = $fromState->getExitEvent();
            if ($exitEvent !== null) {
                if ($this->eventDispatcher !== null) {
                    $this->eventDispatcher->dispatch(StateMachineEvents::EVENT_EXIT, new StateMachineEvent($this, $fromState, $exitEvent));
                }

                $this->runAction($exitEvent);
            }
        }

        $transition = $this->getTransition($fromState, $event);
        $transition->setToken($fromState->getToken());
        $this->previousState = $fromState;
        $this->currentState = null;
        if ($this->eventDispatcher !== null) {
            $this->eventDispatcher->dispatch(StateMachineEvents::EVENT_TRANSITION, new StateMachineEvent($this, null, $event, $transition));
        }
        $this->runAction($event, $transition);
        $transition->getToState()->setToken($transition->getToken());
        $toState = $this->stateCollection->getCurrentState();
        $this->currentState = $toState;
        $this->transitionLog[] = $this->createTransitionLogEntry($transition);

        if ($toState instanceof StateActionInterface) {
            $entryEvent = $toState->getEntryEvent();
            if ($entryEvent !== null) {
                if ($this->eventDispatcher !== null) {
                    $this->eventDispatcher->dispatch(StateMachineEvents::EVENT_ENTRY, new StateMachineEvent($this, $toState, $entryEvent));
                }

                $this->runAction($entryEvent);
            }
        }
    }
private function transition(TransitionalStateInterface $fromState, EventInterface $event)
    {
        if ($fromState instanceof StateActionInterface) {
            $exitEvent = $fromState->getExitEvent();
            if ($exitEvent !== null) {
                if ($this->eventDispatcher !== null) {
                    $this->eventDispatcher->dispatch(StateMachineEvents::EVENT_EXIT, new StateMachineEvent($this, $fromState, $exitEvent));
                }

                $this->runAction($exitEvent);
            }
        }

        $transition = $this->getTransition($fromState, $event);
        $transition->setToken($fromState->getToken());
        $this->previousState = $fromState;
        $this->currentState = null;
        if ($this->eventDispatcher !== null) {
            $this->eventDispatcher->dispatch(StateMachineEvents::EVENT_TRANSITION, new StateMachineEvent($this, null, $event, $transition));
        }
        $this->runAction($event, $transition);
        $transition->getToState()->setToken($transition->getToken());
        $toState = $this->stateCollection->getCurrentState();
        $this->currentState = $toState;
        $this->transitionLog[] = $this->createTransitionLogEntry($transition);

        if ($toState instanceof StateActionInterface) {
            $entryEvent = $toState->getEntryEvent();
            if ($entryEvent !== null) {
                if ($this->eventDispatcher !== null) {
                    $this->eventDispatcher->dispatch(StateMachineEvents::EVENT_ENTRY, new StateMachineEvent($this, $toState, $entryEvent));
                }

                $this->runAction($entryEvent);
            }
        }
    }
private function transition ( TransitionalStateInterface $ fromState , EventInterface $ event ) { if ( $ fromState instanceof StateActionInterface ) { $ exitEvent = $ fromState -> getExitEvent ( ) ; if ( $ exitEvent !== null ) { if ( $ this -> eventDispatcher !== null ) { $ this -> eventDispatcher -> dispatch ( StateMachineEvents :: EVENT_EXIT , new StateMachineEvent ( $ this , $ fromState , $ exitEvent ) ) ; } $ this -> runAction ( $ exitEvent ) ; } } $ transition = $ this -> getTransition ( $ fromState , $ event ) ; $ transition -> setToken ( $ fromState -> getToken ( ) ) ; $ this -> previousState = $ fromState ; $ this -> currentState = null ; if ( $ this -> eventDispatcher !== null ) { $ this -> eventDispatcher -> dispatch ( StateMachineEvents :: EVENT_TRANSITION , new StateMachineEvent ( $ this , null , $ event , $ transition ) ) ; } $ this -> runAction ( $ event , $ transition ) ; $ transition -> getToState ( ) -> setToken ( $ transition -> getToken ( ) ) ; $ toState = $ this -> stateCollection -> getCurrentState ( ) ; $ this -> currentState = $ toState ; $ this -> transitionLog [ ] = $ this -> createTransitionLogEntry ( $ transition ) ; if ( $ toState instanceof StateActionInterface ) { $ entryEvent = $ toState -> getEntryEvent ( ) ; if ( $ entryEvent !== null ) { if ( $ this -> eventDispatcher !== null ) { $ this -> eventDispatcher -> dispatch ( StateMachineEvents :: EVENT_ENTRY , new StateMachineEvent ( $ this , $ toState , $ entryEvent ) ) ; } $ this -> runAction ( $ entryEvent ) ; } } }
Transitions to the next state.

@param TransitionalStateInterface $fromState
@param EventInterface             $event
Transitions to the next state .