Navigation Menu

Skip to content

Commit

Permalink
bug #43940 [FrameworkBundle] Fix logic in workflow:dump between workf…
Browse files Browse the repository at this point in the history
…low name and workflow id (noniagriconomie)

This PR was merged into the 5.4 branch.

Discussion
----------

[FrameworkBundle] Fix logic in workflow:dump between workflow name and workflow id

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #43938
| License       | MIT

As described in #43938 (comment)
the command need a workflow name as argument, but the array contains workflows ids (prefix `workflow|state_machine`)

Commits
-------

d043641 [FrameworkBundle] Fix logic in workflow:dump between workflow name and workflow id
  • Loading branch information
fabpot committed Nov 5, 2021
2 parents d7ea3de + d043641 commit 8a9e826
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/Symfony/Bundle/FrameworkBundle/Command/WorkflowDumpCommand.php
Expand Up @@ -19,6 +19,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\Dumper\GraphvizDumper;
use Symfony\Component\Workflow\Dumper\MermaidDumper;
use Symfony\Component\Workflow\Dumper\PlantUmlDumper;
Expand All @@ -34,6 +35,10 @@ class WorkflowDumpCommand extends Command
{
protected static $defaultName = 'workflow:dump';
protected static $defaultDescription = 'Dump a workflow';
/**
* string is the service id
* @var array<string, Definition>
*/
private $workflows = [];

private const DUMP_FORMAT_OPTIONS = [
Expand Down Expand Up @@ -79,13 +84,21 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$workflowId = $input->getArgument('name');
$workflowName = $input->getArgument('name');

$workflow = null;

if (!\in_array($workflowId, array_keys($this->workflows), true)) {
throw new InvalidArgumentException(sprintf('No service found for "workflow.%1$s" nor "state_machine.%1$s".', $workflowId));
if (isset($this->workflows['workflow.'.$workflowName])) {
$workflow = $this->workflows['workflow.'.$workflowName];
$type = 'workflow';
} elseif (isset($this->workflows['state_machine.'.$workflowName])) {
$workflow = $this->workflows['state_machine.'.$workflowName];
$type = 'state_machine';
}

$type = explode('.', $workflowId)[0];
if (null === $workflow) {
throw new InvalidArgumentException(sprintf('No service found for "workflow.%1$s" nor "state_machine.%1$s".', $workflowName));
}

switch ($input->getOption('dump-format')) {
case 'puml':
Expand All @@ -109,10 +122,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$marking->mark($place);
}

$workflow = $this->workflows[$workflowId];

$options = [
'name' => $workflowId,
'name' => $workflowName,
'nofooter' => true,
'graph' => [
'label' => $input->getOption('label'),
Expand Down

0 comments on commit 8a9e826

Please sign in to comment.