Skip to content

Commit 14760cf

Browse files
committed
Allow multiple transitions with the same name
This works in Symfony's Workflow but laravel-workflow doesn't have a way to reference multiple transitions with the same name in the config file. This patch adds support for the alternative notation referenced in symfony/symfony#22558 that uses a `name` field rather than inferring the transition name from the key. E.g. ``` 't1' => [ 'from' => 'a', 'to' => 'b', ] ``` becomes ``` [ 'name' => 't1', 'from' => 'a', 'to' => 'b', ] ``` which allows multiple transitions with the same name.
1 parent 1e8cf1f commit 14760cf

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/WorkflowRegistry.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public function __construct(array $config)
4848
$builder = new DefinitionBuilder($workflowData['places']);
4949

5050
foreach ($workflowData['transitions'] as $transitionName => $transition) {
51+
if (!is_string($transitionName)) {
52+
$transitionName = $transition['name'];
53+
}
54+
5155
$builder->addTransition(new Transition($transitionName, $transition['from'], $transition['to']));
5256
}
5357

0 commit comments

Comments
 (0)