Skip to content

Commit 3f08a79

Browse files
authored
Add --with-metadata support for workflow:dump command
1 parent 97cbe03 commit 3f08a79

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,10 @@ You can change the image format with the `--format` option. By default the forma
573573

574574
php artisan workflow:dump workflow_name --format=jpg
575575

576+
Similar to [Symfony](https://symfony.com/doc/current/workflow/dumping-workflows.html#styling). You can use `--with-metadata` to include workflow's metadata
577+
578+
php artisan workflow:dump workflow_name --with-metadata
579+
576580
If you would like to output to a different directory than root, you can use the `--disk` and `--path` options to set the Storage disk (`local` by default) and path (`root_path()` by default).
577581

578582
php artisan workflow:dump workflow-name --class=App\\BlogPost --disk=s3 --path="workflows/diagrams/"

src/Commands/WorkflowDumpCommand.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class WorkflowDumpCommand extends Command
2727
{--class= : the support class name}
2828
{--format=png : the image format}
2929
{--disk=local : the storage disk name}
30-
{--path= : the optional path within selected disk}';
30+
{--path= : the optional path within selected disk}
31+
{--with-metadata : dumps metadata beneath the label }';
3132

3233
/**
3334
* The console command description.
@@ -50,6 +51,7 @@ public function handle()
5051
$config = Config::get('workflow');
5152
$disk = $this->option('disk');
5253
$optionalPath = $this->option('path');
54+
$withMetadata = $this->option('with-metadata');
5355

5456
if ($disk === 'local') {
5557
$optionalPath ??= '.';
@@ -69,6 +71,10 @@ public function handle()
6971
' Please specify a valid support class with the --class option.');
7072
}
7173

74+
$dumper_options = [
75+
'with-metadata' => $withMetadata,
76+
];
77+
7278
$subject = new $class();
7379
$workflow = Workflow::get($subject, $workflowName);
7480
$definition = $workflow->getDefinition();
@@ -83,7 +89,7 @@ public function handle()
8389

8490
$process = new Process($dotCommand);
8591
$process->setWorkingDirectory($path);
86-
$process->setInput($dumper->dump($definition));
92+
$process->setInput($dumper->dump($definition, options: $dumper_options));
8793
$process->mustRun();
8894
}
8995
}

0 commit comments

Comments
 (0)