Skip to content

Commit 3990b36

Browse files
committed
[Workflow] Add a link to mermaid.live from the profiler
1 parent e63b188 commit 3990b36

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

DataCollector/WorkflowDataCollector.php

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,33 +88,46 @@ public function getCallsCount(): int
8888
return $i;
8989
}
9090

91+
public function hash(string $string): string
92+
{
93+
return hash('xxh128', $string);
94+
}
95+
96+
public function buildMermaidLiveLink(string $name): string
97+
{
98+
$payload = [
99+
'code' => $this->data['workflows'][$name]['dump'],
100+
'mermaid' => '{"theme": "default"}',
101+
'autoSync' => false,
102+
];
103+
104+
$compressed = zlib_encode(json_encode($payload), ZLIB_ENCODING_DEFLATE);
105+
106+
$suffix = rtrim(strtr(base64_encode($compressed), '+/', '-_'), '=');
107+
108+
return "https://mermaid.live/edit#pako:{$suffix}";
109+
}
110+
91111
protected function getCasters(): array
92112
{
93113
return [
94114
...parent::getCasters(),
95-
TransitionBlocker::class => function ($v, array $a, Stub $s, $isNested) {
96-
unset(
97-
$a[\sprintf(Caster::PATTERN_PRIVATE, $v::class, 'code')],
98-
$a[\sprintf(Caster::PATTERN_PRIVATE, $v::class, 'parameters')],
99-
);
115+
TransitionBlocker::class => static function ($v, array $a, Stub $s) {
116+
unset($a[\sprintf(Caster::PATTERN_PRIVATE, $v::class, 'code')]);
117+
unset($a[\sprintf(Caster::PATTERN_PRIVATE, $v::class, 'parameters')]);
100118

101119
$s->cut += 2;
102120

103121
return $a;
104122
},
105-
Marking::class => function ($v, array $a, Stub $s, $isNested) {
123+
Marking::class => static function ($v, array $a) {
106124
$a[Caster::PREFIX_VIRTUAL.'.places'] = array_keys($v->getPlaces());
107125

108126
return $a;
109127
},
110128
];
111129
}
112130

113-
public function hash(string $string): string
114-
{
115-
return hash('xxh128', $string);
116-
}
117-
118131
private function getEventListeners(WorkflowInterface $workflow): array
119132
{
120133
$listeners = [];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy