Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions config/workflow.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

return [
'straight' => [
'straight' => [
'type' => 'state_machine',
'marking_store' => [
'type' => 'single_state',
Expand All @@ -16,7 +16,10 @@
't2' => [
'from' => 'b',
'to' => 'c',
]
],
],
'options' => [
'node' => ['fontname' => 'SimHei'],
],
]
],
];
17 changes: 8 additions & 9 deletions src/Commands/WorkflowDumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Illuminate\Console\Command;
use Symfony\Component\Process\Process;
use Symfony\Component\Workflow\Dumper\GraphvizDumper;
use Symfony\Component\Workflow\Workflow as SynfonyWorkflow;
use Workflow;

/**
Expand Down Expand Up @@ -40,30 +39,30 @@ class WorkflowDumpCommand extends Command
*/
public function handle()
{
$workflowName = $this->argument('workflow');
$format = $this->option('format');
$class = $this->option('class');
$config = Config::get('workflow');
$workflowName = $this->argument('workflow');
$format = $this->option('format');
$class = $this->option('class');
$config = Config::get('workflow');

if (!isset($config[$workflowName])) {
throw new Exception("Workflow $workflowName is not configured.");
}

if (false === array_search($class, $config[$workflowName]['supports'])) {
throw new Exception("Workflow $workflowName has no support for class $class.".
' Please specify a valid support class with the --class option.');
' Please specify a valid support class with the --class option.');
}

$subject = new $class;
$workflow = Workflow::get($subject, $workflowName);
$subject = new $class();
$workflow = Workflow::get($subject, $workflowName);
$definition = $workflow->getDefinition();

$dumper = new GraphvizDumper();

$dotCommand = "dot -T$format -o $workflowName.$format";

$process = new Process($dotCommand);
$process->setInput($dumper->dump($definition));
$process->setInput($dumper->dump($definition, null, $config[$workflowName]['options'] ?? []));
$process->mustRun();
}
}