feature #26079 [Workflow] Remove constraints on transition/place name + Updated Dumper (lyrixx)

This PR was merged into the 4.1-dev branch.

Discussion
----------

[Workflow] Remove constraints on transition/place name + Updated Dumper

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

(ping @Plopix : I changed a bit the puml dumper)

Commits
-------

55a5a7a [Workflow] Remove constraints on transition/place name + Updated Dumper
This commit is contained in:
Grégoire Pineau 2018-02-09 15:46:03 +01:00
commit f6d741982a
27 changed files with 359 additions and 378 deletions

View File

@ -11,7 +11,6 @@
namespace Symfony\Component\Workflow;
use Symfony\Component\Workflow\Exception\InvalidArgumentException;
use Symfony\Component\Workflow\Exception\LogicException;
/**
@ -82,10 +81,6 @@ final class Definition
private function addPlace(string $place)
{
if (!preg_match('{^[\w_-]+$}', $place)) {
throw new InvalidArgumentException(sprintf('The place "%s" contains invalid characters.', $place));
}
if (!count($this->places)) {
$this->initialPlace = $place;
}

View File

@ -11,8 +11,6 @@
namespace Symfony\Component\Workflow;
use Symfony\Component\Workflow\Exception\InvalidArgumentException;
/**
* Builds a definition.
*
@ -77,10 +75,6 @@ class DefinitionBuilder
*/
public function addPlace($place)
{
if (!preg_match('{^[\w_-]+$}', $place)) {
throw new InvalidArgumentException(sprintf('The place "%s" contains invalid characters.', $place));
}
if (!$this->places) {
$this->initialPlace = $place;
}

View File

@ -107,7 +107,7 @@ class GraphvizDumper implements DumperInterface
$code = '';
foreach ($places as $id => $place) {
$code .= sprintf(" place_%s [label=\"%s\", shape=circle%s];\n", $this->dotize($id), $id, $this->addAttributes($place['attributes']));
$code .= sprintf(" place_%s [label=\"%s\", shape=circle%s];\n", $this->dotize($id), $this->escape($id), $this->addAttributes($place['attributes']));
}
return $code;
@ -121,7 +121,7 @@ class GraphvizDumper implements DumperInterface
$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']));
$code .= sprintf(" transition_%s [label=\"%s\", shape=box%s];\n", $this->dotize($place['name']), $this->escape($place['name']), $this->addAttributes($place['attributes']));
}
return $code;
@ -198,7 +198,15 @@ class GraphvizDumper implements DumperInterface
*/
protected function dotize($id)
{
return strtolower(preg_replace('/[^\w]/i', '_', $id));
return hash('sha1', $id);
}
/**
* @internal
*/
protected function escape(string $string): string
{
return addslashes($string);
}
private function addAttributes(array $attributes): string
@ -206,7 +214,7 @@ class GraphvizDumper implements DumperInterface
$code = array();
foreach ($attributes as $k => $v) {
$code[] = sprintf('%s="%s"', $k, $v);
$code[] = sprintf('%s="%s"', $k, $this->escape($v));
}
return $code ? ', '.implode(', ', $code) : '';

View File

@ -34,8 +34,8 @@ UnrujbYjjz0NnsObkTgnmolqJD4QgGUYTQiNe8eIjtx4b6Vv8nPGpncn3NJ8Geo9W9VW2wGACm_JzgIO
qM53XHDUwhY0TAwPug3OG9NonRFhO8ynF3I4unuAMDHmSrXH57V1RGvl9jafuZF9ZhqjWOEh98y0tUYGsUxkBSllIyBdT2oM5Fn2-ut-fzsq_cQNuL6Uvwqr
knh4RrvOKzxZfLV3s0rs_R_1SdYt3VxeQ1_y2_W2
}';
private const INITIAL = 'initial';
private const MARKED = 'marked';
private const INITIAL = '<<initial>>';
private const MARKED = '<<marked>>';
const STATEMACHINE_TRANSITION = 'arrow';
const WORKFLOW_TRANSITION = 'square';
@ -45,11 +45,11 @@ knh4RrvOKzxZfLV3s0rs_R_1SdYt3VxeQ1_y2_W2
'titleBorderRoundCorner' => 15,
'titleBorderThickness' => 2,
'state' => array(
'BackgroundColor<<'.self::INITIAL.'>>' => '#87b741',
'BackgroundColor<<'.self::MARKED.'>>' => '#3887C6',
'BackgroundColor'.self::INITIAL => '#87b741',
'BackgroundColor'.self::MARKED => '#3887C6',
'BorderColor' => '#3887C6',
'BorderColor<<'.self::MARKED.'>>' => 'Black',
'FontColor<<'.self::MARKED.'>>' => 'White',
'BorderColor'.self::MARKED => 'Black',
'FontColor'.self::MARKED => 'White',
),
'agent' => array(
'BackgroundColor' => '#ffffff',
@ -63,7 +63,7 @@ knh4RrvOKzxZfLV3s0rs_R_1SdYt3VxeQ1_y2_W2
public function __construct(string $transitionType = null)
{
if (!in_array($transitionType, self::TRANSITION_TYPES)) {
throw new InvalidArgumentException("Transition type '{$transitionType}' does not exist.");
throw new InvalidArgumentException("Transition type '$transitionType' does not exist.");
}
$this->transitionType = $transitionType;
}
@ -73,23 +73,28 @@ knh4RrvOKzxZfLV3s0rs_R_1SdYt3VxeQ1_y2_W2
$options = array_replace_recursive(self::DEFAULT_OPTIONS, $options);
$code = $this->initialize($options);
foreach ($definition->getPlaces() as $place) {
$placeEscaped = $this->escape($place);
$code[] =
"state {$place}".
($definition->getInitialPlace() === $place ? ' <<'.self::INITIAL.'>>' : '').
($marking && $marking->has($place) ? ' <<'.self::MARKED.'>>' : '');
"state $placeEscaped".
($definition->getInitialPlace() === $place ? ' '.self::INITIAL : '').
($marking && $marking->has($place) ? ' '.self::MARKED : '');
}
if ($this->isWorkflowTransitionType()) {
foreach ($definition->getTransitions() as $transition) {
$code[] = "agent {$transition->getName()}";
$transitionEscaped = $this->escape($transition->getName());
$code[] = "agent $transitionEscaped";
}
}
foreach ($definition->getTransitions() as $transition) {
$transitionEscaped = $this->escape($transition->getName());
foreach ($transition->getFroms() as $from) {
$fromEscaped = $this->escape($from);
foreach ($transition->getTos() as $to) {
$toEscaped = $this->escape($to);
if ($this->isWorkflowTransitionType()) {
$lines = array(
"{$from} --> {$transition->getName()}",
"{$transition->getName()} --> {$to}",
"$fromEscaped --> $transitionEscaped",
"$transitionEscaped --> $toEscaped",
);
foreach ($lines as $line) {
if (!in_array($line, $code)) {
@ -97,7 +102,7 @@ knh4RrvOKzxZfLV3s0rs_R_1SdYt3VxeQ1_y2_W2
}
}
} else {
$code[] = "{$from} --> {$to}: {$transition->getName()}";
$code[] = "$fromEscaped --> $toEscaped: $transitionEscaped";
}
}
}
@ -114,10 +119,7 @@ knh4RrvOKzxZfLV3s0rs_R_1SdYt3VxeQ1_y2_W2
private function startPuml(array $options): string
{
$start = '@startuml'.PHP_EOL;
if ($this->isWorkflowTransitionType()) {
$start .= 'allow_mixing'.PHP_EOL;
}
$start .= 'allow_mixing'.PHP_EOL;
if ($options['nofooter'] ?? false) {
return $start;
@ -169,4 +171,10 @@ knh4RrvOKzxZfLV3s0rs_R_1SdYt3VxeQ1_y2_W2
return $code;
}
private function escape(string $string): string
{
// It's not possible to escape property double quote, so let's remove it
return '"'.str_replace('"', '', $string).'"';
}
}

View File

@ -71,7 +71,7 @@ class StateMachineGraphvizDumper extends GraphvizDumper
foreach ($edges as $id => $edges) {
foreach ($edges as $edge) {
$code .= sprintf(" place_%s -> place_%s [label=\"%s\" style=\"%s\"];\n", $this->dotize($id), $this->dotize($edge['to']), $edge['name'], 'solid');
$code .= sprintf(" place_%s -> place_%s [label=\"%s\" style=\"%s\"];\n", $this->dotize($id), $this->dotize($edge['to']), $this->escape($edge['name']), 'solid');
}
}

View File

@ -8,14 +8,6 @@ use Symfony\Component\Workflow\Transition;
class DefinitionBuilderTest extends TestCase
{
/**
* @expectedException \Symfony\Component\Workflow\Exception\InvalidArgumentException
*/
public function testAddPlaceInvalidName()
{
$builder = new DefinitionBuilder(array('a"', 'b'));
}
public function testSetInitialPlace()
{
$builder = new DefinitionBuilder(array('a', 'b'));

View File

@ -18,15 +18,6 @@ class DefinitionTest extends TestCase
$this->assertEquals('a', $definition->getInitialPlace());
}
/**
* @expectedException \Symfony\Component\Workflow\Exception\InvalidArgumentException
*/
public function testAddPlacesInvalidArgument()
{
$places = array('a"', 'e"');
$definition = new Definition($places, array());
}
public function testSetInitialPlace()
{
$places = range('a', 'e');

View File

@ -66,33 +66,33 @@ class GraphvizDumperTest extends TestCase
node [fontsize="9" fontname="Arial" color="#333333" fillcolor="lightblue" fixedsize="1" width="1"];
edge [fontsize="9" fontname="Arial" color="#333333" arrowhead="normal" arrowsize="0.5"];
place_a [label="a", shape=circle, style="filled"];
place_b [label="b", shape=circle, color="#FF0000", shape="doublecircle"];
place_c [label="c", shape=circle];
place_d [label="d", shape=circle];
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"];
place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 [label="a", shape=circle, style="filled"];
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="b", shape=circle, color="#FF0000", shape="doublecircle"];
place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="c", shape=circle];
place_3c363836cf4e16666669a25da280a1865c2d2874 [label="d", shape=circle];
place_58e6b3a414a1e090dfc6029add0f3555ccba127f [label="e", shape=circle];
place_4a0a19218e082a343a1b17e5333409af9d98f0f5 [label="f", shape=circle];
place_54fd1711209fb1c0781092374132c66e79e2241b [label="g", shape=circle];
transition_e5353879bd69bfddcb465dad176ff52db8319d6f [label="t1", shape=box, shape="box", regular="1"];
transition_2a5bd02710e975a7fbb92da876655950fbd5e70d [label="t2", shape=box, shape="box", regular="1"];
transition_4358694eeb098c6708ae914a10562ce722bbbc34 [label="t3", shape=box, shape="box", regular="1"];
transition_a9dfb15be45a5f3128784c80c733f2cdee2f756a [label="t4", shape=box, shape="box", regular="1"];
transition_bf55e75fa263cbbc2529db49da43cb7f1d370b88 [label="t5", shape=box, shape="box", regular="1"];
transition_e92a96c0e3a20d87ace74ab7871931a8f9f25943 [label="t6", shape=box, shape="box", regular="1"];
place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -> transition_e5353879bd69bfddcb465dad176ff52db8319d6f [style="solid"];
transition_e5353879bd69bfddcb465dad176ff52db8319d6f -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [style="solid"];
transition_e5353879bd69bfddcb465dad176ff52db8319d6f -> place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [style="solid"];
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> transition_2a5bd02710e975a7fbb92da876655950fbd5e70d [style="solid"];
place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 -> transition_2a5bd02710e975a7fbb92da876655950fbd5e70d [style="solid"];
transition_2a5bd02710e975a7fbb92da876655950fbd5e70d -> place_3c363836cf4e16666669a25da280a1865c2d2874 [style="solid"];
place_3c363836cf4e16666669a25da280a1865c2d2874 -> transition_4358694eeb098c6708ae914a10562ce722bbbc34 [style="solid"];
transition_4358694eeb098c6708ae914a10562ce722bbbc34 -> place_58e6b3a414a1e090dfc6029add0f3555ccba127f [style="solid"];
place_3c363836cf4e16666669a25da280a1865c2d2874 -> transition_a9dfb15be45a5f3128784c80c733f2cdee2f756a [style="solid"];
transition_a9dfb15be45a5f3128784c80c733f2cdee2f756a -> place_4a0a19218e082a343a1b17e5333409af9d98f0f5 [style="solid"];
place_58e6b3a414a1e090dfc6029add0f3555ccba127f -> transition_bf55e75fa263cbbc2529db49da43cb7f1d370b88 [style="solid"];
transition_bf55e75fa263cbbc2529db49da43cb7f1d370b88 -> place_54fd1711209fb1c0781092374132c66e79e2241b [style="solid"];
place_4a0a19218e082a343a1b17e5333409af9d98f0f5 -> transition_e92a96c0e3a20d87ace74ab7871931a8f9f25943 [style="solid"];
transition_e92a96c0e3a20d87ace74ab7871931a8f9f25943 -> place_54fd1711209fb1c0781092374132c66e79e2241b [style="solid"];
}
';
}
@ -104,15 +104,15 @@ class GraphvizDumperTest extends TestCase
node [fontsize="9" fontname="Arial" color="#333333" fillcolor="lightblue" fixedsize="1" width="1"];
edge [fontsize="9" fontname="Arial" color="#333333" arrowhead="normal" arrowsize="0.5"];
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"];
place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 [label="a", shape=circle, style="filled"];
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="b", shape=circle];
place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="c", shape=circle, color="#FF0000", shape="doublecircle"];
transition_e5353879bd69bfddcb465dad176ff52db8319d6f [label="t1", shape=box, shape="box", regular="1"];
transition_2a5bd02710e975a7fbb92da876655950fbd5e70d [label="t2", shape=box, shape="box", regular="1"];
place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -> transition_e5353879bd69bfddcb465dad176ff52db8319d6f [style="solid"];
transition_e5353879bd69bfddcb465dad176ff52db8319d6f -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [style="solid"];
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> transition_2a5bd02710e975a7fbb92da876655950fbd5e70d [style="solid"];
transition_2a5bd02710e975a7fbb92da876655950fbd5e70d -> place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [style="solid"];
}
';
}
@ -124,33 +124,33 @@ class GraphvizDumperTest extends TestCase
node [fontsize="9" fontname="Arial" color="#333333" fillcolor="lightblue" fixedsize="1" width="1"];
edge [fontsize="9" fontname="Arial" color="#333333" arrowhead="normal" arrowsize="0.5"];
place_a [label="a", shape=circle, style="filled"];
place_b [label="b", shape=circle];
place_c [label="c", shape=circle];
place_d [label="d", shape=circle];
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"];
place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 [label="a", shape=circle, style="filled"];
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="b", shape=circle];
place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="c", shape=circle];
place_3c363836cf4e16666669a25da280a1865c2d2874 [label="d", shape=circle];
place_58e6b3a414a1e090dfc6029add0f3555ccba127f [label="e", shape=circle];
place_4a0a19218e082a343a1b17e5333409af9d98f0f5 [label="f", shape=circle];
place_54fd1711209fb1c0781092374132c66e79e2241b [label="g", shape=circle];
transition_e5353879bd69bfddcb465dad176ff52db8319d6f [label="t1", shape=box, shape="box", regular="1"];
transition_2a5bd02710e975a7fbb92da876655950fbd5e70d [label="t2", shape=box, shape="box", regular="1"];
transition_4358694eeb098c6708ae914a10562ce722bbbc34 [label="t3", shape=box, shape="box", regular="1"];
transition_a9dfb15be45a5f3128784c80c733f2cdee2f756a [label="t4", shape=box, shape="box", regular="1"];
transition_bf55e75fa263cbbc2529db49da43cb7f1d370b88 [label="t5", shape=box, shape="box", regular="1"];
transition_e92a96c0e3a20d87ace74ab7871931a8f9f25943 [label="t6", shape=box, shape="box", regular="1"];
place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -> transition_e5353879bd69bfddcb465dad176ff52db8319d6f [style="solid"];
transition_e5353879bd69bfddcb465dad176ff52db8319d6f -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [style="solid"];
transition_e5353879bd69bfddcb465dad176ff52db8319d6f -> place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [style="solid"];
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> transition_2a5bd02710e975a7fbb92da876655950fbd5e70d [style="solid"];
place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 -> transition_2a5bd02710e975a7fbb92da876655950fbd5e70d [style="solid"];
transition_2a5bd02710e975a7fbb92da876655950fbd5e70d -> place_3c363836cf4e16666669a25da280a1865c2d2874 [style="solid"];
place_3c363836cf4e16666669a25da280a1865c2d2874 -> transition_4358694eeb098c6708ae914a10562ce722bbbc34 [style="solid"];
transition_4358694eeb098c6708ae914a10562ce722bbbc34 -> place_58e6b3a414a1e090dfc6029add0f3555ccba127f [style="solid"];
place_3c363836cf4e16666669a25da280a1865c2d2874 -> transition_a9dfb15be45a5f3128784c80c733f2cdee2f756a [style="solid"];
transition_a9dfb15be45a5f3128784c80c733f2cdee2f756a -> place_4a0a19218e082a343a1b17e5333409af9d98f0f5 [style="solid"];
place_58e6b3a414a1e090dfc6029add0f3555ccba127f -> transition_bf55e75fa263cbbc2529db49da43cb7f1d370b88 [style="solid"];
transition_bf55e75fa263cbbc2529db49da43cb7f1d370b88 -> place_54fd1711209fb1c0781092374132c66e79e2241b [style="solid"];
place_4a0a19218e082a343a1b17e5333409af9d98f0f5 -> transition_e92a96c0e3a20d87ace74ab7871931a8f9f25943 [style="solid"];
transition_e92a96c0e3a20d87ace74ab7871931a8f9f25943 -> place_54fd1711209fb1c0781092374132c66e79e2241b [style="solid"];
}
';
}
@ -162,15 +162,15 @@ class GraphvizDumperTest extends TestCase
node [fontsize="9" fontname="Arial" color="#333333" fillcolor="lightblue" fixedsize="1" width="1"];
edge [fontsize="9" fontname="Arial" color="#333333" arrowhead="normal" arrowsize="0.5"];
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"];
place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 [label="a", shape=circle, style="filled"];
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="b", shape=circle];
place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="c", shape=circle];
transition_e5353879bd69bfddcb465dad176ff52db8319d6f [label="t1", shape=box, shape="box", regular="1"];
transition_2a5bd02710e975a7fbb92da876655950fbd5e70d [label="t2", shape=box, shape="box", regular="1"];
place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -> transition_e5353879bd69bfddcb465dad176ff52db8319d6f [style="solid"];
transition_e5353879bd69bfddcb465dad176ff52db8319d6f -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [style="solid"];
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> transition_2a5bd02710e975a7fbb92da876655950fbd5e70d [style="solid"];
transition_2a5bd02710e975a7fbb92da876655950fbd5e70d -> place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [style="solid"];
}
';
}

View File

@ -30,14 +30,14 @@ digraph workflow {
node [fontsize="9" fontname="Arial" color="#333333" fillcolor="lightblue" fixedsize="1" width="1"];
edge [fontsize="9" fontname="Arial" color="#333333" arrowhead="normal" arrowsize="0.5"];
place_a [label="a", shape=circle, style="filled"];
place_b [label="b", shape=circle];
place_c [label="c", shape=circle];
place_d [label="d", shape=circle];
place_a -> place_b [label="t1" style="solid"];
place_d -> place_b [label="t1" style="solid"];
place_b -> place_c [label="t2" style="solid"];
place_b -> place_d [label="t3" style="solid"];
place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 [label="a", shape=circle, style="filled"];
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="b", shape=circle];
place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="c", shape=circle];
place_3c363836cf4e16666669a25da280a1865c2d2874 [label="d", shape=circle];
place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="t1" style="solid"];
place_3c363836cf4e16666669a25da280a1865c2d2874 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="t1" style="solid"];
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="t2" style="solid"];
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_3c363836cf4e16666669a25da280a1865c2d2874 [label="t3" style="solid"];
}
EOGRAPH;
@ -56,14 +56,14 @@ digraph workflow {
node [fontsize="9" fontname="Arial" color="#333333" fillcolor="lightblue" fixedsize="1" width="1"];
edge [fontsize="9" fontname="Arial" color="#333333" arrowhead="normal" arrowsize="0.5"];
place_a [label="a", shape=circle, style="filled"];
place_b [label="b", shape=circle, color="#FF0000", shape="doublecircle"];
place_c [label="c", shape=circle];
place_d [label="d", shape=circle];
place_a -> place_b [label="t1" style="solid"];
place_d -> place_b [label="t1" style="solid"];
place_b -> place_c [label="t2" style="solid"];
place_b -> place_d [label="t3" style="solid"];
place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 [label="a", shape=circle, style="filled"];
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="b", shape=circle, color="#FF0000", shape="doublecircle"];
place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="c", shape=circle];
place_3c363836cf4e16666669a25da280a1865c2d2874 [label="d", shape=circle];
place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="t1" style="solid"];
place_3c363836cf4e16666669a25da280a1865c2d2874 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="t1" style="solid"];
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="t2" style="solid"];
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_3c363836cf4e16666669a25da280a1865c2d2874 [label="t3" style="solid"];
}
EOGRAPH;

View File

@ -7,15 +7,6 @@ use Symfony\Component\Workflow\Transition;
class TransitionTest extends TestCase
{
/**
* @expectedException \Symfony\Component\Workflow\Exception\InvalidArgumentException
* @expectedExceptionMessage The transition "foo.bar" contains invalid characters.
*/
public function testValidateName()
{
$transition = new Transition('foo.bar', 'a', 'b');
}
public function testConstructor()
{
$transition = new Transition('name', 'a', 'b');

View File

@ -1,4 +1,5 @@
@startuml
allow_mixing
title ComplexDiagram
skinparam titleBorderRoundCorner 15
skinparam titleBorderThickness 2
@ -9,19 +10,19 @@ skinparam state {
BorderColor<<marked>> Black
FontColor<<marked>> White
}
state a <<initial>>
state b
state c <<marked>>
state d
state e <<marked>>
state f
state g
a --> b: t1
a --> c: t1
b --> d: t2
c --> d: t2
d --> e: t3
d --> f: t4
e --> g: t5
f --> g: t6
state "a" <<initial>>
state "b"
state "c" <<marked>>
state "d"
state "e" <<marked>>
state "f"
state "g"
"a" --> "b": "t1"
"a" --> "c": "t1"
"b" --> "d": "t2"
"c" --> "d": "t2"
"d" --> "e": "t3"
"d" --> "f": "t4"
"e" --> "g": "t5"
"f" --> "g": "t6"
@enduml

View File

@ -1,4 +1,5 @@
@startuml
allow_mixing
sprite $sf_logo [81x20/16z] {
hPNRaYiX24K1xwBo_tyx6-qaCtDEJ-KXLYMTLbp0HWcHZr3KRDJ8z94HG3jZn4_mijbQ2ryJoFePtXLWA_qxyGy19DpdY_10z11ZAbGjFHRwcEbcKx5-wqsV
yIMo8StMCHKh8ZUxnEwrZiwRAUOvy1lLcPQF4lEFAjhzMd5WOAqvKflS0Enx8PbihiSYXM8ClGVAseIWTAjCgVSAcnYbQG79xKFsZ0VnDCNc7AVBoPSMcTsX
@ -17,20 +18,20 @@ skinparam state {
BorderColor<<marked>> Black
FontColor<<marked>> White
}
state a <<initial>>
state b
state c <<marked>>
state d
state e <<marked>>
state f
state g
a --> b: t1
a --> c: t1
b --> d: t2
c --> d: t2
d --> e: t3
d --> f: t4
e --> g: t5
f --> g: t6
state "a" <<initial>>
state "b"
state "c" <<marked>>
state "d"
state "e" <<marked>>
state "f"
state "g"
"a" --> "b": "t1"
"a" --> "c": "t1"
"b" --> "d": "t2"
"c" --> "d": "t2"
"d" --> "e": "t3"
"d" --> "f": "t4"
"e" --> "g": "t5"
"f" --> "g": "t6"
footer \nGenerated by <$sf_logo> **Workflow Component** and **PlantUML**
@enduml

View File

@ -1,4 +1,5 @@
@startuml
allow_mixing
title ComplexDiagram
skinparam titleBorderRoundCorner 15
skinparam titleBorderThickness 2
@ -9,19 +10,19 @@ skinparam state {
BorderColor<<marked>> Black
FontColor<<marked>> White
}
state a <<initial>>
state b
state c
state d
state e
state f
state g
a --> b: t1
a --> c: t1
b --> d: t2
c --> d: t2
d --> e: t3
d --> f: t4
e --> g: t5
f --> g: t6
state "a" <<initial>>
state "b"
state "c"
state "d"
state "e"
state "f"
state "g"
"a" --> "b": "t1"
"a" --> "c": "t1"
"b" --> "d": "t2"
"c" --> "d": "t2"
"d" --> "e": "t3"
"d" --> "f": "t4"
"e" --> "g": "t5"
"f" --> "g": "t6"
@enduml

View File

@ -1,4 +1,5 @@
@startuml
allow_mixing
sprite $sf_logo [81x20/16z] {
hPNRaYiX24K1xwBo_tyx6-qaCtDEJ-KXLYMTLbp0HWcHZr3KRDJ8z94HG3jZn4_mijbQ2ryJoFePtXLWA_qxyGy19DpdY_10z11ZAbGjFHRwcEbcKx5-wqsV
yIMo8StMCHKh8ZUxnEwrZiwRAUOvy1lLcPQF4lEFAjhzMd5WOAqvKflS0Enx8PbihiSYXM8ClGVAseIWTAjCgVSAcnYbQG79xKFsZ0VnDCNc7AVBoPSMcTsX
@ -17,20 +18,20 @@ skinparam state {
BorderColor<<marked>> Black
FontColor<<marked>> White
}
state a <<initial>>
state b
state c
state d
state e
state f
state g
a --> b: t1
a --> c: t1
b --> d: t2
c --> d: t2
d --> e: t3
d --> f: t4
e --> g: t5
f --> g: t6
state "a" <<initial>>
state "b"
state "c"
state "d"
state "e"
state "f"
state "g"
"a" --> "b": "t1"
"a" --> "c": "t1"
"b" --> "d": "t2"
"c" --> "d": "t2"
"d" --> "e": "t3"
"d" --> "f": "t4"
"e" --> "g": "t5"
"f" --> "g": "t6"
footer \nGenerated by <$sf_logo> **Workflow Component** and **PlantUML**
@enduml

View File

@ -1,4 +1,5 @@
@startuml
allow_mixing
title SimpleDiagram
skinparam titleBorderRoundCorner 15
skinparam titleBorderThickness 2
@ -9,9 +10,9 @@ skinparam state {
BorderColor<<marked>> Black
FontColor<<marked>> White
}
state a <<initial>>
state b <<marked>>
state c
a --> b: t1
b --> c: t2
state "a" <<initial>>
state "b" <<marked>>
state "c"
"a" --> "b": "t1"
"b" --> "c": "t2"
@enduml

View File

@ -1,4 +1,5 @@
@startuml
allow_mixing
sprite $sf_logo [81x20/16z] {
hPNRaYiX24K1xwBo_tyx6-qaCtDEJ-KXLYMTLbp0HWcHZr3KRDJ8z94HG3jZn4_mijbQ2ryJoFePtXLWA_qxyGy19DpdY_10z11ZAbGjFHRwcEbcKx5-wqsV
yIMo8StMCHKh8ZUxnEwrZiwRAUOvy1lLcPQF4lEFAjhzMd5WOAqvKflS0Enx8PbihiSYXM8ClGVAseIWTAjCgVSAcnYbQG79xKFsZ0VnDCNc7AVBoPSMcTsX
@ -17,10 +18,10 @@ skinparam state {
BorderColor<<marked>> Black
FontColor<<marked>> White
}
state a <<initial>>
state b <<marked>>
state c
a --> b: t1
b --> c: t2
state "a" <<initial>>
state "b" <<marked>>
state "c"
"a" --> "b": "t1"
"b" --> "c": "t2"
footer \nGenerated by <$sf_logo> **Workflow Component** and **PlantUML**
@enduml

View File

@ -1,4 +1,5 @@
@startuml
allow_mixing
title SimpleDiagram
skinparam titleBorderRoundCorner 15
skinparam titleBorderThickness 2
@ -9,9 +10,9 @@ skinparam state {
BorderColor<<marked>> Black
FontColor<<marked>> White
}
state a <<initial>>
state b
state c
a --> b: t1
b --> c: t2
state "a" <<initial>>
state "b"
state "c"
"a" --> "b": "t1"
"b" --> "c": "t2"
@enduml

View File

@ -1,4 +1,5 @@
@startuml
allow_mixing
sprite $sf_logo [81x20/16z] {
hPNRaYiX24K1xwBo_tyx6-qaCtDEJ-KXLYMTLbp0HWcHZr3KRDJ8z94HG3jZn4_mijbQ2ryJoFePtXLWA_qxyGy19DpdY_10z11ZAbGjFHRwcEbcKx5-wqsV
yIMo8StMCHKh8ZUxnEwrZiwRAUOvy1lLcPQF4lEFAjhzMd5WOAqvKflS0Enx8PbihiSYXM8ClGVAseIWTAjCgVSAcnYbQG79xKFsZ0VnDCNc7AVBoPSMcTsX
@ -17,10 +18,10 @@ skinparam state {
BorderColor<<marked>> Black
FontColor<<marked>> White
}
state a <<initial>>
state b
state c
a --> b: t1
b --> c: t2
state "a" <<initial>>
state "b"
state "c"
"a" --> "b": "t1"
"b" --> "c": "t2"
footer \nGenerated by <$sf_logo> **Workflow Component** and **PlantUML**
@enduml

View File

@ -14,31 +14,31 @@ skinparam agent {
BackgroundColor #ffffff
BorderColor #3887C6
}
state a <<initial>>
state b
state c <<marked>>
state d
state e <<marked>>
state f
state g
agent t1
agent t2
agent t3
agent t4
agent t5
agent t6
a --> t1
t1 --> b
t1 --> c
b --> t2
t2 --> d
c --> t2
d --> t3
t3 --> e
d --> t4
t4 --> f
e --> t5
t5 --> g
f --> t6
t6 --> g
state "a" <<initial>>
state "b"
state "c" <<marked>>
state "d"
state "e" <<marked>>
state "f"
state "g"
agent "t1"
agent "t2"
agent "t3"
agent "t4"
agent "t5"
agent "t6"
"a" --> "t1"
"t1" --> "b"
"t1" --> "c"
"b" --> "t2"
"t2" --> "d"
"c" --> "t2"
"d" --> "t3"
"t3" --> "e"
"d" --> "t4"
"t4" --> "f"
"e" --> "t5"
"t5" --> "g"
"f" --> "t6"
"t6" --> "g"
@enduml

View File

@ -22,32 +22,32 @@ skinparam agent {
BackgroundColor #ffffff
BorderColor #3887C6
}
state a <<initial>>
state b
state c <<marked>>
state d
state e <<marked>>
state f
state g
agent t1
agent t2
agent t3
agent t4
agent t5
agent t6
a --> t1
t1 --> b
t1 --> c
b --> t2
t2 --> d
c --> t2
d --> t3
t3 --> e
d --> t4
t4 --> f
e --> t5
t5 --> g
f --> t6
t6 --> g
state "a" <<initial>>
state "b"
state "c" <<marked>>
state "d"
state "e" <<marked>>
state "f"
state "g"
agent "t1"
agent "t2"
agent "t3"
agent "t4"
agent "t5"
agent "t6"
"a" --> "t1"
"t1" --> "b"
"t1" --> "c"
"b" --> "t2"
"t2" --> "d"
"c" --> "t2"
"d" --> "t3"
"t3" --> "e"
"d" --> "t4"
"t4" --> "f"
"e" --> "t5"
"t5" --> "g"
"f" --> "t6"
"t6" --> "g"
footer \nGenerated by <$sf_logo> **Workflow Component** and **PlantUML**
@enduml

View File

@ -14,31 +14,31 @@ skinparam agent {
BackgroundColor #ffffff
BorderColor #3887C6
}
state a <<initial>>
state b
state c
state d
state e
state f
state g
agent t1
agent t2
agent t3
agent t4
agent t5
agent t6
a --> t1
t1 --> b
t1 --> c
b --> t2
t2 --> d
c --> t2
d --> t3
t3 --> e
d --> t4
t4 --> f
e --> t5
t5 --> g
f --> t6
t6 --> g
state "a" <<initial>>
state "b"
state "c"
state "d"
state "e"
state "f"
state "g"
agent "t1"
agent "t2"
agent "t3"
agent "t4"
agent "t5"
agent "t6"
"a" --> "t1"
"t1" --> "b"
"t1" --> "c"
"b" --> "t2"
"t2" --> "d"
"c" --> "t2"
"d" --> "t3"
"t3" --> "e"
"d" --> "t4"
"t4" --> "f"
"e" --> "t5"
"t5" --> "g"
"f" --> "t6"
"t6" --> "g"
@enduml

View File

@ -22,32 +22,32 @@ skinparam agent {
BackgroundColor #ffffff
BorderColor #3887C6
}
state a <<initial>>
state b
state c
state d
state e
state f
state g
agent t1
agent t2
agent t3
agent t4
agent t5
agent t6
a --> t1
t1 --> b
t1 --> c
b --> t2
t2 --> d
c --> t2
d --> t3
t3 --> e
d --> t4
t4 --> f
e --> t5
t5 --> g
f --> t6
t6 --> g
state "a" <<initial>>
state "b"
state "c"
state "d"
state "e"
state "f"
state "g"
agent "t1"
agent "t2"
agent "t3"
agent "t4"
agent "t5"
agent "t6"
"a" --> "t1"
"t1" --> "b"
"t1" --> "c"
"b" --> "t2"
"t2" --> "d"
"c" --> "t2"
"d" --> "t3"
"t3" --> "e"
"d" --> "t4"
"t4" --> "f"
"e" --> "t5"
"t5" --> "g"
"f" --> "t6"
"t6" --> "g"
footer \nGenerated by <$sf_logo> **Workflow Component** and **PlantUML**
@enduml

View File

@ -14,13 +14,13 @@ skinparam agent {
BackgroundColor #ffffff
BorderColor #3887C6
}
state a <<initial>>
state b <<marked>>
state c
agent t1
agent t2
a --> t1
t1 --> b
b --> t2
t2 --> c
state "a" <<initial>>
state "b" <<marked>>
state "c"
agent "t1"
agent "t2"
"a" --> "t1"
"t1" --> "b"
"b" --> "t2"
"t2" --> "c"
@enduml

View File

@ -22,14 +22,14 @@ skinparam agent {
BackgroundColor #ffffff
BorderColor #3887C6
}
state a <<initial>>
state b <<marked>>
state c
agent t1
agent t2
a --> t1
t1 --> b
b --> t2
t2 --> c
state "a" <<initial>>
state "b" <<marked>>
state "c"
agent "t1"
agent "t2"
"a" --> "t1"
"t1" --> "b"
"b" --> "t2"
"t2" --> "c"
footer \nGenerated by <$sf_logo> **Workflow Component** and **PlantUML**
@enduml

View File

@ -14,13 +14,13 @@ skinparam agent {
BackgroundColor #ffffff
BorderColor #3887C6
}
state a <<initial>>
state b
state c
agent t1
agent t2
a --> t1
t1 --> b
b --> t2
t2 --> c
state "a" <<initial>>
state "b"
state "c"
agent "t1"
agent "t2"
"a" --> "t1"
"t1" --> "b"
"b" --> "t2"
"t2" --> "c"
@enduml

View File

@ -22,14 +22,14 @@ skinparam agent {
BackgroundColor #ffffff
BorderColor #3887C6
}
state a <<initial>>
state b
state c
agent t1
agent t2
a --> t1
t1 --> b
b --> t2
t2 --> c
state "a" <<initial>>
state "b"
state "c"
agent "t1"
agent "t2"
"a" --> "t1"
"t1" --> "b"
"b" --> "t2"
"t2" --> "c"
footer \nGenerated by <$sf_logo> **Workflow Component** and **PlantUML**
@enduml

View File

@ -11,8 +11,6 @@
namespace Symfony\Component\Workflow;
use Symfony\Component\Workflow\Exception\InvalidArgumentException;
/**
* @author Fabien Potencier <fabien@symfony.com>
* @author Grégoire Pineau <lyrixx@lyrixx.info>
@ -30,10 +28,6 @@ class Transition
*/
public function __construct(string $name, $froms, $tos)
{
if (!preg_match('{^[\w_-]+$}', $name)) {
throw new InvalidArgumentException(sprintf('The transition "%s" contains invalid characters.', $name));
}
$this->name = $name;
$this->froms = (array) $froms;
$this->tos = (array) $tos;