private function addTransitions(Digraph $graph, StateMachine $stateMachine) { foreach ($stateMachine->getStates() as $stateName) { $state = $stateMachine->getState($stateName); foreach ($state->getTransitions() as $transitionName) { $transition = $stateMachine->getTransition($transitionName); $graph->beginEdge(array($stateName, $transition->getState()), array('label' => $transitionName))->end(); } } }
/** * Adds all transitions as edges. * * @param \Finite\StateMachine\StateMachineInterface $stateMachine */ private function addEdges(StateMachineInterface $stateMachine) { $states = $stateMachine->getStates(); foreach ($states as $sName) { $state = $stateMachine->getState($sName); $transitions = $state->getTransitions(); foreach ($transitions as $tName) { $trans = $stateMachine->getTransition($tName); $attributes = $this->getEdgeDefaultAttributes($trans); if ($this->visitors) { try { foreach ($this->visitors as $visitor) { $attributes = $visitor->getEdgeAttributes($attributes, $trans, $state, $stateMachine); } } catch (SkipElementException $ex) { continue; } } $this->graph->beginEdge([$state->getName(), $trans->getState()], $attributes)->end(); } } }
/** * Adds all transitions as edges. * * @param \Finite\StateMachine\StateMachineInterface $stateMachine */ private function addEdges(StateMachineInterface $stateMachine) { $states = $stateMachine->getStates(); foreach ($states as $name) { $state = $stateMachine->getState($name); /* @var $state \Finite\State\StateInterface */ $transitions = $state->getTransitions(); foreach ($transitions as $name) { $trans = $stateMachine->getTransition($name); /* @var $trans Finite\Transition\TransitionInterface */ $this->graph->beginEdge(array($state->getName(), $trans->getState()), array('label' => $trans->getName()))->end(); } } }