Skip to content

Commit c6b664c

Browse files
committed
bug symfony#20460 [FrameworkBundle] Fixed WorkflowCommand to support state machines (HeahDude)
This PR was merged into the 3.2-dev branch. Discussion ---------- [FrameworkBundle] Fixed WorkflowCommand to support state machines | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | ~ Commits ------- 4fcce4c [FrameworkBundle] Fixed WorkflowCommand to support state machines
2 parents b376d92 + 4fcce4c commit c6b664c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/WorkflowDumpCommand.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Console\Output\OutputInterface;
1717
use Symfony\Component\Workflow\Dumper\GraphvizDumper;
1818
use Symfony\Component\Workflow\Marking;
19+
use Symfony\Component\Workflow\Workflow;
1920

2021
/**
2122
* @author Grégoire Pineau <[email protected]>
@@ -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

Comments
 (0)