Metabor\Statemachine\Graph\GraphBuilder::addTransition PHP Method

addTransition() protected method

protected addTransition ( MetaborStd\Statemachine\StateInterface $state, MetaborStd\Statemachine\TransitionInterface $transition )
$state MetaborStd\Statemachine\StateInterface
$transition MetaborStd\Statemachine\TransitionInterface
    protected function addTransition(StateInterface $state, TransitionInterface $transition)
    {
        $sourceStateVertex = $this->createStatusVertex($state);
        $targetStateVertex = $this->createStatusVertex($transition->getTargetState());
        $edge = $sourceStateVertex->createEdgeTo($targetStateVertex);
        $label = $this->getTransitionLabel($state, $transition);
        if ($label) {
            if (method_exists($edge, 'setLayoutAttribute')) {
                $edge->setLayoutAttribute('label', $label);
            } else {
                $edge->setAttribute('graphviz.label', $label);
            }
        }
        $eventName = $transition->getEventName();
        if ($eventName) {
            $event = $state->getEvent($eventName);
            if ($event instanceof \ArrayAccess) {
                $layout = $this->getLayoutOptions($event, $this->eventLayout);
                if (method_exists($edge, 'setLayout')) {
                    $edge->setLayout($layout);
                } else {
                    foreach ($layout as $name => $value) {
                        $edge->setAttribute('graphviz.' . $name, $value);
                    }
                }
            }
        }
    }