-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Workflow] Add support for weighted transitions #60201
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
base: 7.4
Are you sure you want to change the base?
Conversation
c2a67c1
to
5f46eb6
Compare
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Outdated
Show resolved
Hide resolved
5f46eb6
to
9a13aba
Compare
@bkosun Thanks for the review. I addressed your comments |
throw new InvalidDefinitionException(\sprintf('A transition in StateMachine can only have one input. But the transition "%s" in StateMachine "%s" has %d inputs.', $transition->getName(), $name, \count($fromArcs))); | ||
} | ||
foreach ($transition->getToArcs() as $arc) { | ||
if (1 < $arc->weight) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the ex message, should you compare with !== and not < ?
@@ -83,6 +83,11 @@ public function has(string $place): bool | |||
return isset($this->places[$place]); | |||
} | |||
|
|||
public function getTokenCount(string $place): int | |||
{ | |||
return $this->places[$place] ?? 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add php doc for the « places » array shape ?
<xsd:complexType name="arc"> | ||
<xsd:simpleContent> | ||
<xsd:extension base="xsd:string"> | ||
<xsd:attribute name="weight" type="xsd:integer" use="optional" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use="optional"
is the default and we generally don't put it explicitly in our schemas
return new Arc($arc, 1); | ||
} | ||
|
||
throw new \InvalidArgumentException(sprintf('The type of arc is invalid. Expected string or Arc, got "%s".', get_debug_type($arc))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest using TypeError
so that we get the same error type than if we use a parameter type Arc|string
in the future
Allow to handle complex workflow like:
Another example, based on https://demo-symfony-workflow.cleverapps.io/articles/show/1
workflow.webm