Skip to content

Commit

Permalink
bug #20460 [FrameworkBundle] Fixed WorkflowCommand to support state m…
Browse files Browse the repository at this point in the history
…achines (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
  • Loading branch information
lyrixx committed Nov 9, 2016
2 parents b376d92 + 4fcce4c commit c6b664c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/Command/WorkflowDumpCommand.php
Expand Up @@ -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 <lyrixx@lyrixx.info>
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit c6b664c

Please sign in to comment.