8000 bug #51214 [Workflow] Use TRANSITION_TYPE_WORKFLOW for rendering work… · symfony/symfony@d6d233b · GitHub
[go: up one dir, main page]

Skip to content

Commit d6d233b

Browse files
committed
bug #51214 [Workflow] Use TRANSITION_TYPE_WORKFLOW for rendering workflow in profiler (lyrixx)
This PR was merged into the 6.4 branch. Discussion ---------- [Workflow] Use TRANSITION_TYPE_WORKFLOW for rendering workflow in profiler | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | | License | MIT | Doc PR | --- This one is a bit special. Usually a state machine render like this: ![image](https://github.com/symfony/symfony/assets/408368/50f45620-aa88-4fc8-97c2-1049c08b2ee7) As you can see, **transitions** (ex: `start_process`) are not real nodes. They are arrows. And it's not possible to attach events on arrows, only on nodes. That's why I add this hybrid mode, where state machine are rendered like a workflow. It means transitions are renderered as node: ![image](https://github.com/symfony/symfony/assets/408368/80f6731a-2d02-4eab-be2d-77ab67495006) Now, we can attach event on transition nodes. Commits ------- 0cdf2b8 [Workflow] Use TRANSITION_TYPE_WORKFLOW for rendering workflow in profiler
2 parents 15d7b1b + 0cdf2b8 commit d6d233b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Symfony/Component/Workflow/DataCollector/WorkflowDataCollector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
1717
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
1818
use Symfony\Component\Workflow\Dumper\MermaidDumper;
19-
use Symfony\Component\Workflow\StateMachine;
2019

2120
/**
2221
* @author Grégoire Pineau <lyrixx@lyrixx.info>
@@ -35,8 +34,9 @@ public function collect(Request $request, Response $response, \Throwable $except
3534
public function lateCollect(): void
3635
{
3736
foreach ($this->workflows as $workflow) {
38-
$type = $workflow instanceof StateMachine ? MermaidDumper::TRANSITION_TYPE_STATEMACHINE : MermaidDumper::TRANSITION_TYPE_WORKFLOW;
39-
$dumper = new MermaidDumper($type);
37+
// We always use a workflow type because we want to mermaid to
38+
// create a node for transitions
39+
$dumper = new MermaidDumper(MermaidDumper::TRANSITION_TYPE_WORKFLOW);
4040
$this->data['workflows'][$workflow->getName()] = [
4141
'dump' => $dumper->dump($workflow->getDefinition()),
4242
];

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function dump(Definition $definition, Marking $marking = null, array $opt
102102
$to = $placeNameMap[$to];
103103

104104
if (self::TRANSITION_TYPE_STATEMACHINE === $this->transitionType) {
105-
$transitionOutput = $this->styleStatemachineTransition($from, $to, $transitionLabel, $transitionMeta);
105+
$transitionOutput = $this->styleStateMachineTransition($from, $to, $transitionLabel, $transitionMeta);
106106
} else {
107107
$transitionOutput = $this->styleWorkflowTransition($from, $to, $transitionId, $transitionLabel, $transitionMeta);
108108
}
@@ -196,7 +196,7 @@ private function validateTransitionType(string $transitionType): void
196196
}
197197
}
198198

199-
private function styleStatemachineTransition(string $from, string $to, string $transitionLabel, array $transitionMeta): array
199+
private function styleStateMachineTransition(string $from, string $to, string $transitionLabel, array $transitionMeta): array
200200
{
201201
$transitionOutput = [sprintf('%s-->|%s|%s', $from, str_replace("\n", ' ', $this->escape($transitionLabel)), $to)];
202202

0 commit comments

Comments
 (0)
0