[Workflow] Fixed dumping when many transition with same name exist
This commit is contained in:
parent
e197c9ab1b
commit
312a456e04
@ -120,8 +120,8 @@ class GraphvizDumper implements DumperInterface
|
|||||||
{
|
{
|
||||||
$code = '';
|
$code = '';
|
||||||
|
|
||||||
foreach ($transitions as $place) {
|
foreach ($transitions as $i => $place) {
|
||||||
$code .= sprintf(" transition_%s [label=\"%s\", shape=box%s];\n", $this->dotize($place['name']), $place['name'], $this->addAttributes($place['attributes']));
|
$code .= sprintf(" transition_%d [label=\"%s\", shape=box%s];\n", $this->dotize($i), $place['name'], $this->addAttributes($place['attributes']));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $code;
|
return $code;
|
||||||
@ -134,12 +134,13 @@ class GraphvizDumper implements DumperInterface
|
|||||||
{
|
{
|
||||||
$dotEdges = [];
|
$dotEdges = [];
|
||||||
|
|
||||||
foreach ($definition->getTransitions() as $transition) {
|
foreach ($definition->getTransitions() as $i => $transition) {
|
||||||
foreach ($transition->getFroms() as $from) {
|
foreach ($transition->getFroms() as $from) {
|
||||||
$dotEdges[] = [
|
$dotEdges[] = [
|
||||||
'from' => $from,
|
'from' => $from,
|
||||||
'to' => $transition->getName(),
|
'to' => $transition->getName(),
|
||||||
'direction' => 'from',
|
'direction' => 'from',
|
||||||
|
'transition_number' => $i,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
foreach ($transition->getTos() as $to) {
|
foreach ($transition->getTos() as $to) {
|
||||||
@ -147,6 +148,7 @@ class GraphvizDumper implements DumperInterface
|
|||||||
'from' => $transition->getName(),
|
'from' => $transition->getName(),
|
||||||
'to' => $to,
|
'to' => $to,
|
||||||
'direction' => 'to',
|
'direction' => 'to',
|
||||||
|
'transition_number' => $i,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,12 +164,17 @@ class GraphvizDumper implements DumperInterface
|
|||||||
$code = '';
|
$code = '';
|
||||||
|
|
||||||
foreach ($edges as $edge) {
|
foreach ($edges as $edge) {
|
||||||
$code .= sprintf(" %s_%s -> %s_%s [style=\"solid\"];\n",
|
if ('from' === $edge['direction']) {
|
||||||
'from' === $edge['direction'] ? 'place' : 'transition',
|
$code .= sprintf(" place_%s -> transition_%d [style=\"solid\"];\n",
|
||||||
$this->dotize($edge['from']),
|
$this->dotize($edge['from']),
|
||||||
'from' === $edge['direction'] ? 'transition' : 'place',
|
$this->dotize($edge['transition_number'])
|
||||||
$this->dotize($edge['to'])
|
);
|
||||||
);
|
} else {
|
||||||
|
$code .= sprintf(" transition_%d -> place_%s [style=\"solid\"];\n",
|
||||||
|
$this->dotize($edge['transition_number']),
|
||||||
|
$this->dotize($edge['to'])
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $code;
|
return $code;
|
||||||
|
@ -73,26 +73,26 @@ class GraphvizDumperTest extends TestCase
|
|||||||
place_e [label="e", shape=circle];
|
place_e [label="e", shape=circle];
|
||||||
place_f [label="f", shape=circle];
|
place_f [label="f", shape=circle];
|
||||||
place_g [label="g", shape=circle];
|
place_g [label="g", shape=circle];
|
||||||
transition_t1 [label="t1", shape=box, shape="box", regular="1"];
|
transition_0 [label="t1", shape=box, shape="box", regular="1"];
|
||||||
transition_t2 [label="t2", shape=box, shape="box", regular="1"];
|
transition_1 [label="t2", shape=box, shape="box", regular="1"];
|
||||||
transition_t3 [label="t3", shape=box, shape="box", regular="1"];
|
transition_2 [label="t3", shape=box, shape="box", regular="1"];
|
||||||
transition_t4 [label="t4", shape=box, shape="box", regular="1"];
|
transition_3 [label="t4", shape=box, shape="box", regular="1"];
|
||||||
transition_t5 [label="t5", shape=box, shape="box", regular="1"];
|
transition_4 [label="t5", shape=box, shape="box", regular="1"];
|
||||||
transition_t6 [label="t6", shape=box, shape="box", regular="1"];
|
transition_5 [label="t6", shape=box, shape="box", regular="1"];
|
||||||
place_a -> transition_t1 [style="solid"];
|
place_a -> transition_0 [style="solid"];
|
||||||
transition_t1 -> place_b [style="solid"];
|
transition_0 -> place_b [style="solid"];
|
||||||
transition_t1 -> place_c [style="solid"];
|
transition_0 -> place_c [style="solid"];
|
||||||
place_b -> transition_t2 [style="solid"];
|
place_b -> transition_1 [style="solid"];
|
||||||
place_c -> transition_t2 [style="solid"];
|
place_c -> transition_1 [style="solid"];
|
||||||
transition_t2 -> place_d [style="solid"];
|
transition_1 -> place_d [style="solid"];
|
||||||
place_d -> transition_t3 [style="solid"];
|
place_d -> transition_2 [style="solid"];
|
||||||
transition_t3 -> place_e [style="solid"];
|
transition_2 -> place_e [style="solid"];
|
||||||
place_d -> transition_t4 [style="solid"];
|
place_d -> transition_3 [style="solid"];
|
||||||
transition_t4 -> place_f [style="solid"];
|
transition_3 -> place_f [style="solid"];
|
||||||
place_e -> transition_t5 [style="solid"];
|
place_e -> transition_4 [style="solid"];
|
||||||
transition_t5 -> place_g [style="solid"];
|
transition_4 -> place_g [style="solid"];
|
||||||
place_f -> transition_t6 [style="solid"];
|
place_f -> transition_5 [style="solid"];
|
||||||
transition_t6 -> place_g [style="solid"];
|
transition_5 -> place_g [style="solid"];
|
||||||
}
|
}
|
||||||
';
|
';
|
||||||
}
|
}
|
||||||
@ -107,12 +107,12 @@ class GraphvizDumperTest extends TestCase
|
|||||||
place_a [label="a", shape=circle, style="filled"];
|
place_a [label="a", shape=circle, style="filled"];
|
||||||
place_b [label="b", shape=circle];
|
place_b [label="b", shape=circle];
|
||||||
place_c [label="c", shape=circle, color="#FF0000", shape="doublecircle"];
|
place_c [label="c", shape=circle, color="#FF0000", shape="doublecircle"];
|
||||||
transition_t1 [label="t1", shape=box, shape="box", regular="1"];
|
transition_0 [label="t1", shape=box, shape="box", regular="1"];
|
||||||
transition_t2 [label="t2", shape=box, shape="box", regular="1"];
|
transition_1 [label="t2", shape=box, shape="box", regular="1"];
|
||||||
place_a -> transition_t1 [style="solid"];
|
place_a -> transition_0 [style="solid"];
|
||||||
transition_t1 -> place_b [style="solid"];
|
transition_0 -> place_b [style="solid"];
|
||||||
place_b -> transition_t2 [style="solid"];
|
place_b -> transition_1 [style="solid"];
|
||||||
transition_t2 -> place_c [style="solid"];
|
transition_1 -> place_c [style="solid"];
|
||||||
}
|
}
|
||||||
';
|
';
|
||||||
}
|
}
|
||||||
@ -131,26 +131,26 @@ class GraphvizDumperTest extends TestCase
|
|||||||
place_e [label="e", shape=circle];
|
place_e [label="e", shape=circle];
|
||||||
place_f [label="f", shape=circle];
|
place_f [label="f", shape=circle];
|
||||||
place_g [label="g", shape=circle];
|
place_g [label="g", shape=circle];
|
||||||
transition_t1 [label="t1", shape=box, shape="box", regular="1"];
|
transition_0 [label="t1", shape=box, shape="box", regular="1"];
|
||||||
transition_t2 [label="t2", shape=box, shape="box", regular="1"];
|
transition_1 [label="t2", shape=box, shape="box", regular="1"];
|
||||||
transition_t3 [label="t3", shape=box, shape="box", regular="1"];
|
transition_2 [label="t3", shape=box, shape="box", regular="1"];
|
||||||
transition_t4 [label="t4", shape=box, shape="box", regular="1"];
|
transition_3 [label="t4", shape=box, shape="box", regular="1"];
|
||||||
transition_t5 [label="t5", shape=box, shape="box", regular="1"];
|
transition_4 [label="t5", shape=box, shape="box", regular="1"];
|
||||||
transition_t6 [label="t6", shape=box, shape="box", regular="1"];
|
transition_5 [label="t6", shape=box, shape="box", regular="1"];
|
||||||
place_a -> transition_t1 [style="solid"];
|
place_a -> transition_0 [style="solid"];
|
||||||
transition_t1 -> place_b [style="solid"];
|
transition_0 -> place_b [style="solid"];
|
||||||
transition_t1 -> place_c [style="solid"];
|
transition_0 -> place_c [style="solid"];
|
||||||
place_b -> transition_t2 [style="solid"];
|
place_b -> transition_1 [style="solid"];
|
||||||
place_c -> transition_t2 [style="solid"];
|
place_c -> transition_1 [style="solid"];
|
||||||
transition_t2 -> place_d [style="solid"];
|
transition_1 -> place_d [style="solid"];
|
||||||
place_d -> transition_t3 [style="solid"];
|
place_d -> transition_2 [style="solid"];
|
||||||
transition_t3 -> place_e [style="solid"];
|
transition_2 -> place_e [style="solid"];
|
||||||
place_d -> transition_t4 [style="solid"];
|
place_d -> transition_3 [style="solid"];
|
||||||
transition_t4 -> place_f [style="solid"];
|
transition_3 -> place_f [style="solid"];
|
||||||
place_e -> transition_t5 [style="solid"];
|
place_e -> transition_4 [style="solid"];
|
||||||
transition_t5 -> place_g [style="solid"];
|
transition_4 -> place_g [style="solid"];
|
||||||
place_f -> transition_t6 [style="solid"];
|
place_f -> transition_5 [style="solid"];
|
||||||
transition_t6 -> place_g [style="solid"];
|
transition_5 -> place_g [style="solid"];
|
||||||
}
|
}
|
||||||
';
|
';
|
||||||
}
|
}
|
||||||
@ -165,12 +165,12 @@ class GraphvizDumperTest extends TestCase
|
|||||||
place_a [label="a", shape=circle, style="filled"];
|
place_a [label="a", shape=circle, style="filled"];
|
||||||
place_b [label="b", shape=circle];
|
place_b [label="b", shape=circle];
|
||||||
place_c [label="c", shape=circle];
|
place_c [label="c", shape=circle];
|
||||||
transition_t1 [label="t1", shape=box, shape="box", regular="1"];
|
transition_0 [label="t1", shape=box, shape="box", regular="1"];
|
||||||
transition_t2 [label="t2", shape=box, shape="box", regular="1"];
|
transition_1 [label="t2", shape=box, shape="box", regular="1"];
|
||||||
place_a -> transition_t1 [style="solid"];
|
place_a -> transition_0 [style="solid"];
|
||||||
transition_t1 -> place_b [style="solid"];
|
transition_0 -> place_b [style="solid"];
|
||||||
place_b -> transition_t2 [style="solid"];
|
place_b -> transition_1 [style="solid"];
|
||||||
transition_t2 -> place_c [style="solid"];
|
transition_1 -> place_c [style="solid"];
|
||||||
}
|
}
|
||||||
';
|
';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user