Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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