public function renderGraph($outputPath = './workflow.png', $stopAfterExecution = true)
    {
        /*
         * This example is based on http://martin-thoma.com/how-to-draw-a-finite-state-machine/
         * Feel free to tweak the rendering output. I have decided do use the most simple
         * implementation over the fancy stuff to avoid additional complexity.
         */
        $template
            = '
            digraph finite_state_machine {
                rankdir=LR;
                size="%d"

                node [shape = doublecircle]; start;
                node [shape = circle];

                %s
            }
        ';

        $pattern = ' %s  -> %s [ label = "%s" ];';

        $_transitions = [];
        foreach ($this->workflowConfiguration['states'] as $state) {
            if (array_key_exists('transitions_from', $state)) {
                $transitions_from = $state['transitions_from'];
                foreach ($transitions_from as $from) {
                    if (is_array($from)) {
                        $_transitions[] = sprintf(
                            $pattern,
                            $from['status'],
                            $state['name'],
                            '<< IF '
                            . $this->convertToStringCondition($from['result']) . ' >>' . $state['name']
                        );
                    } else {
                        $_transitions[] = sprintf($pattern, $from, $state['name'], $state['name']);
                    }
                }
            } else {
                if ('type' == 'exception') {
                    $_transitions[] = 'node [shape = doublecircle]; exception;';
                }
            }
        }
        file_put_contents('/tmp/sm.gv', sprintf($template, count($_transitions) * 2, implode("\n", $_transitions)));
        shell_exec('dot -Tpng /tmp/sm.gv -o ' . $outputPath);

        if ($stopAfterExecution) {
            //exit;
        }
    }
public function renderGraph($outputPath = './workflow.png', $stopAfterExecution = true)
    {
        /*
         * This example is based on http://martin-thoma.com/how-to-draw-a-finite-state-machine/
         * Feel free to tweak the rendering output. I have decided do use the most simple
         * implementation over the fancy stuff to avoid additional complexity.
         */
        $template
            = '
            digraph finite_state_machine {
                rankdir=LR;
                size="%d"

                node [shape = doublecircle]; start;
                node [shape = circle];

                %s
            }
        ';

        $pattern = ' %s  -> %s [ label = "%s" ];';

        $_transitions = [];
        foreach ($this->workflowConfiguration['states'] as $state) {
            if (array_key_exists('transitions_from', $state)) {
                $transitions_from = $state['transitions_from'];
                foreach ($transitions_from as $from) {
                    if (is_array($from)) {
                        $_transitions[] = sprintf(
                            $pattern,
                            $from['status'],
                            $state['name'],
                            '<< IF '
                            . $this->convertToStringCondition($from['result']) . ' >>' . $state['name']
                        );
                    } else {
                        $_transitions[] = sprintf($pattern, $from, $state['name'], $state['name']);
                    }
                }
            } else {
                if ('type' == 'exception') {
                    $_transitions[] = 'node [shape = doublecircle]; exception;';
                }
            }
        }
        file_put_contents('/tmp/sm.gv', sprintf($template, count($_transitions) * 2, implode("\n", $_transitions)));
        shell_exec('dot -Tpng /tmp/sm.gv -o ' . $outputPath);

        if ($stopAfterExecution) {
            //exit;
        }
    }
public function renderGraph ( $ outputPath = './workflow.png' , $ stopAfterExecution = true ) { /*
         * This example is based on http://martin-thoma.com/how-to-draw-a-finite-state-machine/
         * Feel free to tweak the rendering output. I have decided do use the most simple
         * implementation over the fancy stuff to avoid additional complexity.
         */ $ template = '
            digraph finite_state_machine {
                rankdir=LR;
                size="%d"

                node [shape = doublecircle]; start;
                node [shape = circle];

                %s
            }
        ' ; $ pattern = ' %s  -> %s [ label = "%s" ];' ; $ _transitions = [ ] ; foreach ( $ this -> workflowConfiguration [ 'states' ] as $ state ) { if ( array_key_exists ( 'transitions_from' , $ state ) ) { $ transitions_from = $ state [ 'transitions_from' ] ; foreach ( $ transitions_from as $ from ) { if ( is_array ( $ from ) ) { $ _transitions [ ] = sprintf ( $ pattern , $ from [ 'status' ] , $ state [ 'name' ] , '<< IF ' . $ this -> convertToStringCondition ( $ from [ 'result' ] ) . ' >>' . $ state [ 'name' ] ) ; } else { $ _transitions [ ] = sprintf ( $ pattern , $ from , $ state [ 'name' ] , $ state [ 'name' ] ) ; } } } else { if ( 'type' == 'exception' ) { $ _transitions [ ] = 'node [shape = doublecircle]; exception;' ; } } } file_put_contents ( '/tmp/sm.gv' , sprintf ( $ template , count ( $ _transitions ) * 2 , implode ( "\n" , $ _transitions ) ) ) ; shell_exec ( 'dot -Tpng /tmp/sm.gv -o ' . $ outputPath ) ; if ( $ stopAfterExecution ) { //exit; } }
create a graph for the state machine.

@param string     $outputPath         relative path of the generated image
@param bool|false $stopAfterExecution if we want to exit after graphic generation

@return void
create a graph for the state machine .