98 lines
4.9 KiB
YAML
98 lines
4.9 KiB
YAML
name: MermaidDumper
|
|
class_comment: null
|
|
dependencies:
|
|
- name: Definition
|
|
type: class
|
|
source: Symfony\Component\Workflow\Definition
|
|
- name: InvalidArgumentException
|
|
type: class
|
|
source: Symfony\Component\Workflow\Exception\InvalidArgumentException
|
|
- name: Marking
|
|
type: class
|
|
source: Symfony\Component\Workflow\Marking
|
|
properties: []
|
|
methods:
|
|
- name: escape
|
|
visibility: private
|
|
parameters:
|
|
- name: label
|
|
comment: "# * Just tracking the transition id is in some cases inaccurate to\n#\
|
|
\ * get the link's number for styling purposes.\n# */\n# private int $linkCount\
|
|
\ = 0;\n# \n# public function __construct(\n# private string $transitionType,\n\
|
|
# private string $direction = self::DIRECTION_LEFT_TO_RIGHT,\n# ) {\n# $this->validateDirection($direction);\n\
|
|
# $this->validateTransitionType($transitionType);\n# }\n# \n# public function\
|
|
\ dump(Definition $definition, ?Marking $marking = null, array $options = []):\
|
|
\ string\n# {\n# $this->linkCount = 0;\n# $placeNameMap = [];\n# $placeId = 0;\n\
|
|
# \n# $output = ['graph '.$this->direction];\n# \n# $meta = $definition->getMetadataStore();\n\
|
|
# \n# foreach ($definition->getPlaces() as $place) {\n# [$placeNodeName, $placeNode,\
|
|
\ $placeStyle] = $this->preparePlace(\n# $placeId,\n# $place,\n# $meta->getPlaceMetadata($place),\n\
|
|
# \\in_array($place, $definition->getInitialPlaces(), true),\n# $marking?->has($place)\
|
|
\ ?? false\n# );\n# \n# $output[] = $placeNode;\n# \n# if ('' !== $placeStyle)\
|
|
\ {\n# $output[] = $placeStyle;\n# }\n# \n# $placeNameMap[$place] = $placeNodeName;\n\
|
|
# \n# ++$placeId;\n# }\n# \n# foreach ($definition->getTransitions() as $transitionId\
|
|
\ => $transition) {\n# $transitionMeta = $meta->getTransitionMetadata($transition);\n\
|
|
# \n# $transitionLabel = $transition->getName();\n# if (\\array_key_exists('label',\
|
|
\ $transitionMeta)) {\n# $transitionLabel = $transitionMeta['label'];\n# }\n#\
|
|
\ \n# foreach ($transition->getFroms() as $from) {\n# $from = $placeNameMap[$from];\n\
|
|
# \n# foreach ($transition->getTos() as $to) {\n# $to = $placeNameMap[$to];\n\
|
|
# \n# if (self::TRANSITION_TYPE_STATEMACHINE === $this->transitionType) {\n# $transitionOutput\
|
|
\ = $this->styleStateMachineTransition($from, $to, $transitionLabel, $transitionMeta);\n\
|
|
# } else {\n# $transitionOutput = $this->styleWorkflowTransition($from, $to, $transitionId,\
|
|
\ $transitionLabel, $transitionMeta);\n# }\n# \n# foreach ($transitionOutput as\
|
|
\ $line) {\n# if (\\in_array($line, $output)) {\n# // additional links must be\
|
|
\ decremented again to align the styling\n# if (0 < strpos($line, '-->')) {\n\
|
|
# --$this->linkCount;\n# }\n# \n# continue;\n# }\n# \n# $output[] = $line;\n#\
|
|
\ }\n# }\n# }\n# }\n# \n# return implode(\"\\n\", $output);\n# }\n# \n# private\
|
|
\ function preparePlace(int $placeId, string $placeName, array $meta, bool $isInitial,\
|
|
\ bool $hasMarking): array\n# {\n# $placeLabel = $placeName;\n# if (\\array_key_exists('label',\
|
|
\ $meta)) {\n# $placeLabel = $meta['label'];\n# }\n# \n# $placeLabel = $this->escape($placeLabel);\n\
|
|
# \n# $labelShape = '((%s))';\n# if ($isInitial) {\n# $labelShape = '([%s])';\n\
|
|
# }\n# \n# $placeNodeName = 'place'.$placeId;\n# $placeNodeFormat = '%s'.$labelShape;\n\
|
|
# $placeNode = \\sprintf($placeNodeFormat, $placeNodeName, $placeLabel);\n# \n\
|
|
# $placeStyle = $this->styleNode($meta, $placeNodeName, $hasMarking);\n# \n# return\
|
|
\ [$placeNodeName, $placeNode, $placeStyle];\n# }\n# \n# private function styleNode(array\
|
|
\ $meta, string $nodeName, bool $hasMarking = false): string\n# {\n# $nodeStyles\
|
|
\ = [];\n# \n# if (\\array_key_exists('bg_color', $meta)) {\n# $nodeStyles[] =\
|
|
\ \\sprintf(\n# 'fill:%s',\n# $meta['bg_color']\n# );\n# }\n# \n# if ($hasMarking)\
|
|
\ {\n# $nodeStyles[] = 'stroke-width:4px';\n# }\n# \n# if (0 === \\count($nodeStyles))\
|
|
\ {\n# return '';\n# }\n# \n# return \\sprintf('style %s %s', $nodeName, implode(',',\
|
|
\ $nodeStyles));\n# }\n# \n# /**\n# * Replace double quotes with the mermaid escape\
|
|
\ syntax and\n# * ensure all other characters are properly escaped."
|
|
- name: validateDirection
|
|
visibility: public
|
|
parameters:
|
|
- name: direction
|
|
comment: null
|
|
- name: validateTransitionType
|
|
visibility: private
|
|
parameters:
|
|
- name: transitionType
|
|
comment: null
|
|
- name: styleStateMachineTransition
|
|
visibility: private
|
|
parameters:
|
|
- name: from
|
|
- name: to
|
|
- name: transitionLabel
|
|
- name: transitionMeta
|
|
comment: null
|
|
- name: styleWorkflowTransition
|
|
visibility: private
|
|
parameters:
|
|
- name: from
|
|
- name: to
|
|
- name: transitionId
|
|
- name: transitionLabel
|
|
- name: transitionMeta
|
|
comment: null
|
|
- name: styleLink
|
|
visibility: private
|
|
parameters:
|
|
- name: transitionMeta
|
|
comment: null
|
|
traits:
|
|
- Symfony\Component\Workflow\Definition
|
|
- Symfony\Component\Workflow\Exception\InvalidArgumentException
|
|
- Symfony\Component\Workflow\Marking
|
|
interfaces:
|
|
- DumperInterface
|