/** * @param \ArrayAccess $context * @param EventInterface $event */ 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->notify(); $this->selectedTransition = null; $this->lastState = null; } $this->checkTransitions(); } } 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); } }
/** * @see MetaborStd\Statemachine.TransitionInterface::isActive() */ public function isActive($subject, \ArrayAccess $context, EventInterface $event = null) { if ($event) { $result = $event->getName() == $this->eventName; } else { $result = is_null($this->eventName); } if ($this->condition) { $result = $result && $this->condition->checkCondition($subject, $context); } return $result; }