From 720824374a3c0f42d9b74bb78f101066d922dc58 Mon Sep 17 00:00:00 2001 From: wangle <285273592@qq.com> Date: Thu, 2 Apr 2020 19:16:22 +0800 Subject: [PATCH 1/4] get cmd parameters from config for compatibility with chinese --- config/workflow.php | 3 +++ src/Commands/WorkflowDumpCommand.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config/workflow.php b/config/workflow.php index 7c6fd39..fa050ba 100644 --- a/config/workflow.php +++ b/config/workflow.php @@ -18,5 +18,8 @@ 'to' => 'c', ] ], + 'options' => [ + 'node'=>['fontname' => 'SimHei'], + ], ] ]; diff --git a/src/Commands/WorkflowDumpCommand.php b/src/Commands/WorkflowDumpCommand.php index fa008e1..5b2776e 100644 --- a/src/Commands/WorkflowDumpCommand.php +++ b/src/Commands/WorkflowDumpCommand.php @@ -63,7 +63,7 @@ public function handle() $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(); } } From 3b2a5574a98517076c79eeadfcc6cd3a03be6218 Mon Sep 17 00:00:00 2001 From: wangle <285273592@qq.com> Date: Thu, 2 Apr 2020 19:34:18 +0800 Subject: [PATCH 2/4] format --- config/workflow.php | 10 +++++----- src/Commands/WorkflowDumpCommand.php | 15 +++++++-------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/config/workflow.php b/config/workflow.php index fa050ba..8ce43d4 100644 --- a/config/workflow.php +++ b/config/workflow.php @@ -1,7 +1,7 @@ [ + 'straight' => [ 'type' => 'state_machine', 'marking_store' => [ 'type' => 'single_state', @@ -16,10 +16,10 @@ 't2' => [ 'from' => 'b', 'to' => 'c', - ] + ], ], - 'options' => [ - 'node'=>['fontname' => 'SimHei'], + 'options' => [ + 'node' => ['fontname' => 'SimHei'], ], - ] + ], ]; diff --git a/src/Commands/WorkflowDumpCommand.php b/src/Commands/WorkflowDumpCommand.php index 5b2776e..616bab9 100644 --- a/src/Commands/WorkflowDumpCommand.php +++ b/src/Commands/WorkflowDumpCommand.php @@ -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; /** @@ -40,18 +39,18 @@ 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.'); + throw new Exception("Workflow $workflowName has no support for class $class." . + ' Please specify a valid support class with the --class option.'); } $subject = new $class; @@ -63,7 +62,7 @@ public function handle() $dotCommand = "dot -T$format -o $workflowName.$format"; $process = new Process($dotCommand); - $process->setInput($dumper->dump($definition,null,$config[$workflowName]['options'] ?? [])); + $process->setInput($dumper->dump($definition, null, $config[$workflowName]['options'] ?? [])); $process->mustRun(); } } From 7d10163ec9299518ffa10ed80eadd46d6fb79d02 Mon Sep 17 00:00:00 2001 From: wangle <285273592@qq.com> Date: Thu, 2 Apr 2020 19:48:52 +0800 Subject: [PATCH 3/4] format --- src/Commands/WorkflowDumpCommand.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Commands/WorkflowDumpCommand.php b/src/Commands/WorkflowDumpCommand.php index 616bab9..e0d8e8a 100644 --- a/src/Commands/WorkflowDumpCommand.php +++ b/src/Commands/WorkflowDumpCommand.php @@ -40,21 +40,21 @@ class WorkflowDumpCommand extends Command public function handle() { $workflowName = $this->argument('workflow'); - $format = $this->option('format'); - $class = $this->option('class'); - $config = Config::get('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." . + throw new Exception("Workflow $workflowName has no support for class $class.". ' 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(); From f0e30abe727d59dc2b137eb83782d2613e2ef332 Mon Sep 17 00:00:00 2001 From: wangle <285273592@qq.com> Date: Thu, 2 Apr 2020 19:52:05 +0800 Subject: [PATCH 4/4] format --- src/Commands/WorkflowDumpCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/WorkflowDumpCommand.php b/src/Commands/WorkflowDumpCommand.php index e0d8e8a..73ed733 100644 --- a/src/Commands/WorkflowDumpCommand.php +++ b/src/Commands/WorkflowDumpCommand.php @@ -53,7 +53,7 @@ public function handle() ' Please specify a valid support class with the --class option.'); } - $subject = new $class; + $subject = new $class(); $workflow = Workflow::get($subject, $workflowName); $definition = $workflow->getDefinition();