From 4fcce4c465f64e8de3c42f1622293cdf600ccac0 Mon Sep 17 00:00:00 2001 From: HeahDude Date: Wed, 9 Nov 2016 13:53:14 +0100 Subject: [PATCH] [FrameworkBundle] Fixed WorkflowCommand to support state machines --- .../Command/WorkflowDumpCommand.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/WorkflowDumpCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/WorkflowDumpCommand.php index d1b4e2a766d6e..14bb2ced1a90b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/WorkflowDumpCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/WorkflowDumpCommand.php @@ -16,6 +16,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Workflow\Dumper\GraphvizDumper; use Symfony\Component\Workflow\Marking; +use Symfony\Component\Workflow\Workflow; /** * @author Grégoire Pineau @@ -55,7 +56,16 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { - $workflow = $this->getContainer()->get('workflow.'.$input->getArgument('name')); + $container = $this->getContainer(); + $serviceId = $input->getArgument('name'); + if ($container->has('workflow.'.$serviceId)) { + $workflow = $container->get('workflow.'.$serviceId); + } elseif ($container->has('state_machine.'.$serviceId)) { + $workflow = $container->get('state_machine.'.$serviceId); + } else { + throw new \InvalidArgumentException(sprintf('No service found for "workflow.%1$s" nor "state_machine.%1$s".', $serviceId)); + } + $definition = $this->getProperty($workflow, 'definition'); $dumper = new GraphvizDumper(); @@ -70,7 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output) private function getProperty($object, $property) { - $reflectionProperty = new \ReflectionProperty(get_class($object), $property); + $reflectionProperty = new \ReflectionProperty(Workflow::class, $property); $reflectionProperty->setAccessible(true); return $reflectionProperty->getValue($object);