protected function doCheckTransitions(\ArrayAccess $context, EventInterface $event = null)
{
try {
$transitions = $this->currentState->getTransitions();
$activeTransitions = new ActiveTransitionFilter($transitions, $this->getSubject(), $context, $event);
$this->selectedTransition = $this->transitonSelector->selectTransition($activeTransitions);
if ($this->selectedTransition) {
$targetState = $this->selectedTransition->getTargetState();
if ($this->currentState != $targetState) {
$this->lastState = $this->currentState;
$this->currentState = $targetState;
$this->currentContext = $context;
$this->currentEvent = $event;
$this->notify();
$this->currentContext = null;
$this->currentEvent = null;
$this->selectedTransition = null;
$this->lastState = null;
}
$this->checkTransitions($context);
}
} catch (\Exception $exception) {
$message = 'Exception was thrown when doing a transition from current state "' . $this->currentState->getName() . '"';
if ($this->currentEvent instanceof NamedInterface) {
$message .= ' with event "' . $this->currentEvent->getName() . '"';
}
throw new \RuntimeException($message, 0, $exception);
}
}