19
19
use Symfony \Component \Console \Input \InputInterface ;
20
20
use Symfony \Component \Console \Input \InputOption ;
21
21
use Symfony \Component \Console \Output \OutputInterface ;
22
+ use Symfony \Component \Workflow \Definition ;
22
23
use Symfony \Component \Workflow \Dumper \GraphvizDumper ;
23
24
use Symfony \Component \Workflow \Dumper \MermaidDumper ;
24
25
use Symfony \Component \Workflow \Dumper \PlantUmlDumper ;
@@ -34,6 +35,10 @@ class WorkflowDumpCommand extends Command
34
35
{
35
36
protected static $ defaultName = 'workflow:dump ' ;
36
37
protected static $ defaultDescription = 'Dump a workflow ' ;
38
+ /**
39
+ * string is the service id
40
+ * @var array<string, Definition>
41
+ */
37
42
private $ workflows = [];
38
43
39
44
private const DUMP_FORMAT_OPTIONS = [
@@ -79,13 +84,21 @@ protected function configure()
79
84
*/
80
85
protected function execute (InputInterface $ input , OutputInterface $ output ): int
81
86
{
82
- $ workflowId = $ input ->getArgument ('name ' );
87
+ $ workflowName = $ input ->getArgument ('name ' );
88
+
89
+ $ workflow = null ;
83
90
84
- if (!\in_array ($ workflowId , array_keys ($ this ->workflows ), true )) {
85
- throw new InvalidArgumentException (sprintf ('No service found for "workflow.%1$s" nor "state_machine.%1$s". ' , $ workflowId ));
91
+ if (isset ($ this ->workflows ['workflow. ' .$ workflowName ])) {
92
+ $ workflow = $ this ->workflows ['workflow. ' .$ workflowName ];
93
+ $ type = 'workflow ' ;
94
+ } elseif (isset ($ this ->workflows ['state_machine. ' .$ workflowName ])) {
95
+ $ workflow = $ this ->workflows ['state_machine. ' .$ workflowName ];
96
+ $ type = 'state_machine ' ;
86
97
}
87
98
88
- $ type = explode ('. ' , $ workflowId )[0 ];
99
+ if (null === $ workflow ) {
100
+ throw new InvalidArgumentException (sprintf ('No service found for "workflow.%1$s" nor "state_machine.%1$s". ' , $ workflowName ));
101
+ }
89
102
90
103
switch ($ input ->getOption ('dump-format ' )) {
91
104
case 'puml ' :
@@ -109,10 +122,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
109
122
$ marking ->mark ($ place );
110
123
}
111
124
112
- $ workflow = $ this ->workflows [$ workflowId ];
113
-
114
125
$ options = [
115
- 'name ' => $ workflowId ,
126
+ 'name ' => $ workflowName ,
116
127
'nofooter ' => true ,
117
128
'graph ' => [
118
129
'label ' => $ input ->getOption ('label ' ),
0 commit comments