1616use Symfony \Component \Console \Output \OutputInterface ;
1717use Symfony \Component \Workflow \Dumper \GraphvizDumper ;
1818use Symfony \Component \Workflow \Marking ;
19+ use Symfony \Component \Workflow \Workflow ;
1920
2021/**
2122 * @author Grégoire Pineau <lyrixx@lyrixx.info>
@@ -55,7 +56,16 @@ protected function configure()
5556 */
5657 protected function execute (InputInterface $ input , OutputInterface $ output )
5758 {
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+
5969 $ definition = $ this ->getProperty ($ workflow , 'definition ' );
6070
6171 $ dumper = new GraphvizDumper ();
@@ -70,7 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7080
7181 private function getProperty ($ object , $ property )
7282 {
73- $ reflectionProperty = new \ReflectionProperty (get_class ( $ object ) , $ property );
83+ $ reflectionProperty = new \ReflectionProperty (Workflow::class , $ property );
7484 $ reflectionProperty ->setAccessible (true );
7585
7686 return $ reflectionProperty ->getValue ($ object );
0 commit comments