Skip to content
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

add config options #75

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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();
}
}