8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
Description Currently it is possible to instantiate an "invalid" StateMachine. It would be nice to have some checks in place to prevent this.
Example For example:
<?php use Symfony\Component\Workflow\Definition; use Symfony\Component\Workflow\StateMachine; use Symfony\Component\Workflow\Transition; $states = ['created', 'activated', 'deleted']; $stateTransitions = [ new Transition('activate', 'created', 'activated'), new Transition('activate', 'created', 'deleted'), //oops, copy-paste mistake: 'activate' should have been 'delete' ]; $definition = new Definition($states, $stateTransitions); $stateMachine = new StateMachine($definition);
This would result in an "invalid" StateMachine...
Maybe some inspiration can be derived from this implementation of a StateMachine
The text was updated successfully, but these errors were encountered:
cc @lyrixx
Sorry, something went wrong.
Even if there is a typo, this workflow is totally valid. With a state machine, you can have many transitions with the same name and with the same origin. I don't see how we can validate something here. I read the code you linked and they put more limitation on a workflow... so we can not grab this code.
With a state machine, you can have many transitions with the same name and with the same origin.
are you sure about that for a state machine ? Wouldn't you move you to multiple states ?
IIRC, we allow having the same name with different origins.
I think the main issue here is that the validator is not applied on your definition, so you don't run the checks. These checks are not part of the StateMachine constructor for performance reason: if you define your workflow in the config file, Symfony will run the validation during cache warmup, and so running the validation on each instantiation would be useless overhead. See https://github.com/symfony/symfony/tree/4.4/src/Symfony/Component/Workflow/Validator for existing definition validators.
Indeed, a (Finite)StateMachine can only be in one state at a certain moment in time. For WorkFlows this rule does not apply...
Also see https://stackoverflow.com/questions/53980748/whats-the-difference-of-petri-nets-and-finite-state-machines
You make me doubt :) I guess you are right!
@holtkamp As @stof mentionned, some validator already exist. And this issue is already covered
I think we can close this issue, and there is nothing we can do here since everything already exist.
I think we can close this issue,
Indeed, I was not aware of the StateMachineValidator, maybe it can be documented?
Closing issue!
maybe it can be documented?
Good idea. Would you mind open a PR or an issue ?
@lyrixx sure, will give a PR a shot.
I am just in doubt about the proper page to add a "Validation" section:
Add section about Workflows and State Machine validation
74c5379
As suggested in symfony/symfony#33972 (comment)
minor #12541 Add section about Workflows and State Machine validation…
f9a4454
… (holtkamp) This PR was squashed before being merged into the 4.4 branch (closes #12541). Discussion ---------- Add section about Workflows and State Machine validation As suggested in symfony/symfony#33972 (comment) Commits ------- ef7ff0b Add section about Workflows and State Machine validation
No branches or pull requests