Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Intended behavior of workflow:dump fails in dev #60215

Open
@tacman

Description

@tacman

Symfony version(s) affected

7.2

Description

The indended behavior of workflow dump is to use StateMachineGraphvizDumper when the workflow is a type state_machine

            $dumper = ('workflow' === $type) ? new GraphvizDumper() : new StateMachineGraphvizDumper();

However, this fails in dev because $type is incorrectly set, because in dev the workflow class is Symfony\Component\Workflow\Debug\TraceableWorkflow

      $type = $workflow instanceof StateMachine ? 'state_machine' : 'workflow';

Both in WorkflowDumpCommand.php

How to reproduce

git clone [email protected]:lyrixx/SFLive-Paris2016-Workflow.git workflow-demo && cd workflow-demo
composer install
bin/console workflow:dump task --with-metadata --no-debug  | dot -Tsvg -o no-debug-task.svg && open no-debug-task.svg
bin/console workflow:dump task --with-metadata | dot -Tsvg -o task.svg && open task.svg

Produces

Image

Image

Possible Solution

The solution is to define $type based on the $definition of the workflow, not the class.

BUT I like the current behavior! In part because I have a metadata on my transitions, which isn't shown in the StateMachine, only the workflow Graph.

Additional Context

So a better solution is to allow the user to select which renderer to use if it's a state machine. But that's a new feature.

I'm working on a new dumper that adds guard and removes 'description' and if there's interest I'll submit it for 7.4. Because of that, this isn't urgent for me, but I figured I'd submit it in case anyone else was struggling with the inconsistent behavior between debug and no-debug (and previous versions of the dumper).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions