16
16
use Symfony \Component \Console \Output \OutputInterface ;
17
17
use Symfony \Component \Workflow \Dumper \GraphvizDumper ;
18
18
use Symfony \Component \Workflow \Marking ;
19
+ use Symfony \Component \Workflow \Workflow ;
19
20
20
21
/**
21
22
* @author Grégoire Pineau <lyrixx@lyrixx.info>
@@ -55,7 +56,16 @@ protected function configure()
55
56
*/
56
57
protected function execute (InputInterface $ input , OutputInterface $ output )
57
58
{
58
- $ workflow = $ this ->getContainer ()->get ('workflow. ' .$ input ->getArgument ('name ' ));
59
+ $ container = $ this ->getContainer ();
60
+ $ serviceId = $ input ->getArgument ('name ' );
61
+ if ($ container ->has ('workflow. ' .$ serviceId )) {
62
+ $ workflow = $ container ->get ('workflow. ' .$ serviceId );
63
+ } elseif ($ container ->has ('state_machine. ' .$ serviceId )) {
64
+ $ workflow = $ container ->get ('state_machine. ' .$ serviceId );
65
+ } else {
66
+ throw new \InvalidArgumentException (sprintf ('No service found for "workflow.%1$s" nor "state_machine.%1$s". ' , $ serviceId ));
67
+ }
68
+
59
69
$ definition = $ this ->getProperty ($ workflow , 'definition ' );
60
70
61
71
$ dumper = new GraphvizDumper ();
@@ -70,7 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
70
80
71
81
private function getProperty ($ object , $ property )
72
82
{
73
- $ reflectionProperty = new \ReflectionProperty (get_class ( $ object ) , $ property );
83
+ $ reflectionProperty = new \ReflectionProperty (Workflow::class , $ property );
74
84
$ reflectionProperty ->setAccessible (true );
75
85
76
86
return $ reflectionProperty ->getValue ($ object );
0 commit comments