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

Commit a3062c7

Browse filesBrowse files
alexislefebvrefabpot
authored andcommitted
[Workflow] remove new lines from workflow metadata
1 parent daec724 commit a3062c7
Copy full SHA for a3062c7

File tree

Expand file treeCollapse file tree

4 files changed

+14
-6
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+14
-6
lines changed

‎src/Symfony/Component/Workflow/Dumper/MermaidDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/Dumper/MermaidDumper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ private function styleStatemachineTransition(
224224
string $transitionLabel,
225225
array $transitionMeta
226226
): array {
227-
$transitionOutput = [sprintf('%s-->|%s|%s', $from, $this->escape($transitionLabel), $to)];
227+
$transitionOutput = [sprintf('%s-->|%s|%s', $from, str_replace("\n", ' ', $this->escape($transitionLabel)), $to)];
228228

229229
$linkStyle = $this->styleLink($transitionMeta);
230230
if ('' !== $linkStyle) {

‎src/Symfony/Component/Workflow/Dumper/PlantUmlDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/Dumper/PlantUmlDumper.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private function getState(string $place, Definition $definition, Marking $markin
195195
{
196196
$workflowMetadata = $definition->getMetadataStore();
197197

198-
$placeEscaped = $this->escape($place);
198+
$placeEscaped = str_replace("\n", ' ', $this->escape($place));
199199

200200
$output = "state $placeEscaped".
201201
(\in_array($place, $definition->getInitialPlaces(), true) ? ' '.self::INITIAL : '').
@@ -208,7 +208,7 @@ private function getState(string $place, Definition $definition, Marking $markin
208208

209209
$description = $workflowMetadata->getMetadata('description', $place);
210210
if (null !== $description) {
211-
$output .= \PHP_EOL.$placeEscaped.' : '.$description;
211+
$output .= \PHP_EOL.$placeEscaped.' : '.str_replace("\n", ' ', $description);
212212
}
213213

214214
return $output;
@@ -217,6 +217,7 @@ private function getState(string $place, Definition $definition, Marking $markin
217217
private function getTransitionEscapedWithStyle(MetadataStoreInterface $workflowMetadata, Transition $transition, string $to): string
218218
{
219219
$to = $workflowMetadata->getMetadata('label', $transition) ?? $to;
220+
$to = str_replace("\n", ' ', $to);
220221

221222
$color = $workflowMetadata->getMetadata('color', $transition) ?? null;
222223

‎src/Symfony/Component/Workflow/Tests/Dumper/StateMachineGraphvizDumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/Tests/Dumper/StateMachineGraphvizDumperTest.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public function testDumpWithoutMarking()
4444
place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="c", shape=circle];
4545
place_3c363836cf4e16666669a25da280a1865c2d2874 [label="d", shape=circle];
4646
place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="t1" style="solid"];
47-
place_3c363836cf4e16666669a25da280a1865c2d2874 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="My custom transition label 3" style="solid" fontcolor="Grey" color="Red"];
47+
place_3c363836cf4e16666669a25da280a1865c2d2874 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="My custom transition
48+
label 3" style="solid" fontcolor="Grey" color="Red"];
4849
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="t2" style="solid" color="Blue"];
4950
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_3c363836cf4e16666669a25da280a1865c2d2874 [label="t3" style="solid"];
5051
}
@@ -70,7 +71,8 @@ public function testDumpWithMarking()
7071
place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="c", shape=circle];
7172
place_3c363836cf4e16666669a25da280a1865c2d2874 [label="d", shape=circle];
7273
place_86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="t1" style="solid"];
73-
place_3c363836cf4e16666669a25da280a1865c2d2874 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="My custom transition label 3" style="solid" fontcolor="Grey" color="Red"];
74+
place_3c363836cf4e16666669a25da280a1865c2d2874 -> place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 [label="My custom transition
75+
label 3" style="solid" fontcolor="Grey" color="Red"];
7476
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_84a516841ba77a5b4648de2cd0dfcb30ea46dbb4 [label="t2" style="solid" color="Blue"];
7577
place_e9d71f5ee7c92d6dc9e92ffdad17b8bd49418f98 -> place_3c363836cf4e16666669a25da280a1865c2d2874 [label="t3" style="solid"];
7678
}

‎src/Symfony/Component/Workflow/Tests/WorkflowBuilderTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/Tests/WorkflowBuilderTrait.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,13 @@ private function createComplexStateMachineDefinition()
127127
$transitions[] = new Transition('t3', 'b', 'd');
128128

129129
$transitionsMetadata = new \SplObjectStorage();
130+
// PHP 7.2 doesn't allow this heredoc syntax in an array, use a dedicated variable instead
131+
$label = <<<'EOTXT'
132+
My custom transition
133+
label 3
134+
EOTXT;
130135
$transitionsMetadata[$transitionWithMetadataDumpStyle] = [
131-
'label' => 'My custom transition label 3',
136+
'label' => $label,
132137
'color' => 'Grey',
133138
'arrow_color' => 'Red',
134139
];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.