1919use Symfony \Component \Console \Input \InputInterface ;
2020use Symfony \Component \Console \Input \InputOption ;
2121use Symfony \Component \Console \Output \OutputInterface ;
22+ use Symfony \Component \Workflow \Definition ;
2223use Symfony \Component \Workflow \Dumper \GraphvizDumper ;
2324use Symfony \Component \Workflow \Dumper \MermaidDumper ;
2425use Symfony \Component \Workflow \Dumper \PlantUmlDumper ;
@@ -34,6 +35,10 @@ class WorkflowDumpCommand extends Command
3435{
3536 protected static $ defaultName = 'workflow:dump ' ;
3637 protected static $ defaultDescription = 'Dump a workflow ' ;
38+ /**
39+ * string is the service id
40+ * @var array<string, Definition>
41+ */
3742 private $ workflows = [];
3843
3944 private const DUMP_FORMAT_OPTIONS = [
@@ -79,13 +84,21 @@ protected function configure()
7984 */
8085 protected function execute (InputInterface $ input , OutputInterface $ output ): int
8186 {
82- $ workflowId = $ input ->getArgument ('name ' );
87+ $ workflowName = $ input ->getArgument ('name ' );
88+
89+ $ workflow = null ;
8390
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 ' ;
8697 }
8798
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+ }
89102
90103 switch ($ input ->getOption ('dump-format ' )) {
91104 case 'puml ' :
@@ -109,10 +122,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
109122 $ marking ->mark ($ place );
110123 }
111124
112- $ workflow = $ this ->workflows [$ workflowId ];
113-
114125 $ options = [
115- 'name ' => $ workflowId ,
126+ 'name ' => $ workflowName ,
116127 'nofooter ' => true ,
117128 'graph ' => [
118129 'label ' => $ input ->getOption ('label ' ),
0 commit comments