Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Workflow] Fixed dumping when many transition with same name exist #31331

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

Merged
merged 1 commit into from
May 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Workflow] Fixed dumping when many transition with same name exist
  • Loading branch information
lyrixx committed Apr 30, 2019
commit 312a456e044b41eb22cbb49a1733609a33c97b98
25 changes: 16 additions & 9 deletions 25 src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ protected function addTransitions(array $transitions)
{
$code = '';

foreach ($transitions as $place) {
$code .= sprintf(" transition_%s [label=\"%s\", shape=box%s];\n", $this->dotize($place['name']), $place['name'], $this->addAttributes($place['attributes']));
foreach ($transitions as $i => $place) {
$code .= sprintf(" transition_%d [label=\"%s\", shape=box%s];\n", $this->dotize($i), $place['name'], $this->addAttributes($place['attributes']));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lyrixx We could remove the call to dotize here as $i is always an integer, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, in 4.2, we are using a hash, so a string (so I'm going to change %d to %s in 4.2).

}

return $code;
Expand All @@ -134,19 +134,21 @@ protected function findEdges(Definition $definition)
{
$dotEdges = [];

foreach ($definition->getTransitions() as $transition) {
foreach ($definition->getTransitions() as $i => $transition) {
foreach ($transition->getFroms() as $from) {
$dotEdges[] = [
'from' => $from,
'to' => $transition->getName(),
'direction' => 'from',
'transition_number' => $i,
];
}
foreach ($transition->getTos() as $to) {
$dotEdges[] = [
'from' => $transition->getName(),
'to' => $to,
'direction' => 'to',
'transition_number' => $i,
];
}
}
Expand All @@ -162,12 +164,17 @@ protected function addEdges(array $edges)
$code = '';

foreach ($edges as $edge) {
$code .= sprintf(" %s_%s -> %s_%s [style=\"solid\"];\n",
'from' === $edge['direction'] ? 'place' : 'transition',
$this->dotize($edge['from']),
'from' === $edge['direction'] ? 'transition' : 'place',
$this->dotize($edge['to'])
);
if ('from' === $edge['direction']) {
$code .= sprintf(" place_%s -> transition_%d [style=\"solid\"];\n",
$this->dotize($edge['from']),
$this->dotize($edge['transition_number'])
);
} else {
$code .= sprintf(" transition_%d -> place_%s [style=\"solid\"];\n",
$this->dotize($edge['transition_number']),
$this->dotize($edge['to'])
);
}
}

return $code;
Expand Down
104 changes: 52 additions & 52 deletions 104 src/Symfony/Component/Workflow/Tests/Dumper/GraphvizDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,26 @@ public function createComplexWorkflowDefinitionDumpWithMarking()
place_e [label="e", shape=circle];
place_f [label="f", shape=circle];
place_g [label="g", shape=circle];
transition_t1 [label="t1", shape=box, shape="box", regular="1"];
transition_t2 [label="t2", shape=box, shape="box", regular="1"];
transition_t3 [label="t3", shape=box, shape="box", regular="1"];
transition_t4 [label="t4", shape=box, shape="box", regular="1"];
transition_t5 [label="t5", shape=box, shape="box", regular="1"];
transition_t6 [label="t6", shape=box, shape="box", regular="1"];
place_a -> transition_t1 [style="solid"];
transition_t1 -> place_b [style="solid"];
transition_t1 -> place_c [style="solid"];
place_b -> transition_t2 [style="solid"];
place_c -> transition_t2 [style="solid"];
transition_t2 -> place_d [style="solid"];
place_d -> transition_t3 [style="solid"];
transition_t3 -> place_e [style="solid"];
place_d -> transition_t4 [style="solid"];
transition_t4 -> place_f [style="solid"];
place_e -> transition_t5 [style="solid"];
transition_t5 -> place_g [style="solid"];
place_f -> transition_t6 [style="solid"];
transition_t6 -> place_g [style="solid"];
transition_0 [label="t1", shape=box, shape="box", regular="1"];
transition_1 [label="t2", shape=box, shape="box", regular="1"];
transition_2 [label="t3", shape=box, shape="box", regular="1"];
transition_3 [label="t4", shape=box, shape="box", regular="1"];
transition_4 [label="t5", shape=box, shape="box", regular="1"];
transition_5 [label="t6", shape=box, shape="box", regular="1"];
place_a -> transition_0 [style="solid"];
transition_0 -> place_b [style="solid"];
transition_0 -> place_c [style="solid"];
place_b -> transition_1 [style="solid"];
place_c -> transition_1 [style="solid"];
transition_1 -> place_d [style="solid"];
place_d -> transition_2 [style="solid"];
transition_2 -> place_e [style="solid"];
place_d -> transition_3 [style="solid"];
transition_3 -> place_f [style="solid"];
place_e -> transition_4 [style="solid"];
transition_4 -> place_g [style="solid"];
place_f -> transition_5 [style="solid"];
transition_5 -> place_g [style="solid"];
}
';
}
Expand All @@ -107,12 +107,12 @@ public function createSimpleWorkflowDumpWithMarking()
place_a [label="a", shape=circle, style="filled"];
place_b [label="b", shape=circle];
place_c [label="c", shape=circle, color="#FF0000", shape="doublecircle"];
transition_t1 [label="t1", shape=box, shape="box", regular="1"];
transition_t2 [label="t2", shape=box, shape="box", regular="1"];
place_a -> transition_t1 [style="solid"];
transition_t1 -> place_b [style="solid"];
place_b -> transition_t2 [style="solid"];
transition_t2 -> place_c [style="solid"];
transition_0 [label="t1", shape=box, shape="box", regular="1"];
transition_1 [label="t2", shape=box, shape="box", regular="1"];
place_a -> transition_0 [style="solid"];
transition_0 -> place_b [style="solid"];
place_b -> transition_1 [style="solid"];
transition_1 -> place_c [style="solid"];
}
';
}
Expand All @@ -131,26 +131,26 @@ public function provideComplexWorkflowDumpWithoutMarking()
place_e [label="e", shape=circle];
place_f [label="f", shape=circle];
place_g [label="g", shape=circle];
transition_t1 [label="t1", shape=box, shape="box", regular="1"];
transition_t2 [label="t2", shape=box, shape="box", regular="1"];
transition_t3 [label="t3", shape=box, shape="box", regular="1"];
transition_t4 [label="t4", shape=box, shape="box", regular="1"];
transition_t5 [label="t5", shape=box, shape="box", regular="1"];
transition_t6 [label="t6", shape=box, shape="box", regular="1"];
place_a -> transition_t1 [style="solid"];
transition_t1 -> place_b [style="solid"];
transition_t1 -> place_c [style="solid"];
place_b -> transition_t2 [style="solid"];
place_c -> transition_t2 [style="solid"];
transition_t2 -> place_d [style="solid"];
place_d -> transition_t3 [style="solid"];
transition_t3 -> place_e [style="solid"];
place_d -> transition_t4 [style="solid"];
transition_t4 -> place_f [style="solid"];
place_e -> transition_t5 [style="solid"];
transition_t5 -> place_g [style="solid"];
place_f -> transition_t6 [style="solid"];
transition_t6 -> place_g [style="solid"];
transition_0 [label="t1", shape=box, shape="box", regular="1"];
transition_1 [label="t2", shape=box, shape="box", regular="1"];
transition_2 [label="t3", shape=box, shape="box", regular="1"];
transition_3 [label="t4", shape=box, shape="box", regular="1"];
transition_4 [label="t5", shape=box, shape="box", regular="1"];
transition_5 [label="t6", shape=box, shape="box", regular="1"];
place_a -> transition_0 [style="solid"];
transition_0 -> place_b [style="solid"];
transition_0 -> place_c [style="solid"];
place_b -> transition_1 [style="solid"];
place_c -> transition_1 [style="solid"];
transition_1 -> place_d [style="solid"];
place_d -> transition_2 [style="solid"];
transition_2 -> place_e [style="solid"];
place_d -> transition_3 [style="solid"];
transition_3 -> place_f [style="solid"];
place_e -> transition_4 [style="solid"];
transition_4 -> place_g [style="solid"];
place_f -> transition_5 [style="solid"];
transition_5 -> place_g [style="solid"];
}
';
}
Expand All @@ -165,12 +165,12 @@ public function provideSimpleWorkflowDumpWithoutMarking()
place_a [label="a", shape=circle, style="filled"];
place_b [label="b", shape=circle];
place_c [label="c", shape=circle];
transition_t1 [label="t1", shape=box, shape="box", regular="1"];
transition_t2 [label="t2", shape=box, shape="box", regular="1"];
place_a -> transition_t1 [style="solid"];
transition_t1 -> place_b [style="solid"];
place_b -> transition_t2 [style="solid"];
transition_t2 -> place_c [style="solid"];
transition_0 [label="t1", shape=box, shape="box", regular="1"];
transition_1 [label="t2", shape=box, shape="box", regular="1"];
place_a -> transition_0 [style="solid"];
transition_0 -> place_b [style="solid"];
place_b -> transition_1 [style="solid"];
transition_1 -> place_c [style="solid"];
}
';
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.