-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Workflow] Fixed graphviz dumper for state machine #20583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7f71617
to
41568ac
Compare
} elseif ($container->has('state_machine.'.$serviceId)) { | ||
$workflow = $container->get('state_machine.'.$serviceId); | ||
$dumper = new StateMachineGraphvizDumper(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we have a way to dump the state machine in workflow mode ? It is a subset after all.
But anyway, I agree it should not be the default dumping for state machines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this of course means that it should be fixed to work properly, but I know how to do this (stop assuming that transition names are unique identifiers of the transition, as we stopped doing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we have a way to dump the state machine in workflow mode ?
For now, it's not really readable to dump a state machine with the workflow dumper. So IMHO, it's not useful to add a way to do it.
} | ||
|
||
return $code; | ||
} | ||
|
||
private function findEdges(Definition $definition) | ||
protected function findEdges(Definition $definition) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, this should not be protected extension points. This seems like the wrong way to reuse part of the GraphvizDumper (fixing the dumping of transitions to stop assuming unique names might require refactoring private methods, but making them protected forbids this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand what you mean. Could you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are talking about composition, it's not really possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added @internal
everywhere.
41568ac
to
cc949bb
Compare
cc949bb
to
1e92e02
Compare
👍 |
Thank you @lyrixx. |
This PR was merged into the 3.3-dev branch. Discussion ---------- [Workflow] Fixed graphviz dumper for state machine | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20497 | License | MIT | Doc PR | ~ --- Before:  After:  --- Script: ```php <?php require __DIR__.'/vendor/autoload.php'; use Symfony\Component\Workflow\Definition; use Symfony\Component\Workflow\Dumper\StateMachineGraphvizDumper; use Symfony\Component\Workflow\Marking; use Symfony\Component\Workflow\StateMachine; use Symfony\Component\Workflow\Transition; $places = array('a', 'b', 'c', 'd'); $transitions[] = new Transition('t1', 'a', 'b'); $transitions[] = new Transition('t1', 'd', 'b'); $transitions[] = new Transition('t2', 'b', 'c'); $transitions[] = new Transition('t3', 'b', 'd'); $definition = new Definition($places, $transitions); $marking = new Marking(['d' => 1]); echo (new StateMachineGraphvizDumper())->dump($definition, $marking); ``` Commits ------- 1e92e02 [Workflow] Fixed graphviz dumper for state machine
Unless I missed something, this should have been merged in 3.2 instead |
Indeed, thanks for noticing. |
This PR was submitted for the master branch but it was merged into the 3.2 branch instead (closes #20583). Discussion ---------- [Workflow] Fixed graphviz dumper for state machine | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20497 | License | MIT | Doc PR | ~ --- Before:  After:  --- Script: ```php <?php require __DIR__.'/vendor/autoload.php'; use Symfony\Component\Workflow\Definition; use Symfony\Component\Workflow\Dumper\StateMachineGraphvizDumper; use Symfony\Component\Workflow\Marking; use Symfony\Component\Workflow\StateMachine; use Symfony\Component\Workflow\Transition; $places = array('a', 'b', 'c', 'd'); $transitions[] = new Transition('t1', 'a', 'b'); $transitions[] = new Transition('t1', 'd', 'b'); $transitions[] = new Transition('t2', 'b', 'c'); $transitions[] = new Transition('t3', 'b', 'd'); $definition = new Definition($places, $transitions); $marking = new Marking(['d' => 1]); echo (new StateMachineGraphvizDumper())->dump($definition, $marking); ``` Commits ------- 330c069 [Workflow] Fixed graphviz dumper for state machine
Before:


After:
Script: