-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Workflow] Questions and ideas #20774
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
Comments
Event
From my point of view, it's a best practice to flush in the controller and note in a listener. If you flush in the listener, your model could be corrupted. For example, if you plan to send an email after a transition, nothing can guarantee you the email was send. But it's too late because you already save into the DB the new marking. |
Transition parametersI'm not sure about this use case. You are mixing the concern here. I mean: You are using the event as a data bag and IMHO this is not the right place do it. In your example, the tracking number should be a property of the Order. With the new implementation, the tracking number is volatile, and IMHO, it's not a good idea. |
Check the issues in finite... many people had problems with these there. |
One workflow, or multiple state machines?In this example, and after a very quick read of it, I would use a workflow and not a state machine to let the Engine decide if a transition can be enabled or not. |
@Padam87 Having only big issue for many questions is really not easy :/ |
Yep, that was a bad idea :) I still think all of these are valid features, parameters come in handy in the real world, even if it does not make sense in an ideal word. One time I had to pass parameters from an API call result, and on time from an rabbit RPC request. |
@Padam87 Could we close this issue. I think I answered all your questions. Moreover there are related PR open or closed. Feel free to re-open new issue (but with only one topic ;) ) if needed. |
Yes, can be closed, thanks! |
This PR was submitted for the 3.2 branch but it was merged into the 3.3-dev branch instead (closes #20787). Discussion ---------- [Workflow] Added an entered event | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20774 (partially) ; #21433 | License | MIT | Doc PR | - Commits ------- 7a562bd [Workflow] Added an entered event
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I decided to give the workflow component a try, and I have a couple of questions and suggestions.
I have started out with this workflow. I used to do these type of jobs with https://github.com/yohang/Finite, but the new component looks awesome :)
Events
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Workflow/Workflow.php#L129
The marking store is updated only after the
enter
event has been fired. This is not convenient, since I can't flush the entity manager in the listener.The
announce
event is for the next transition as I gather, so listening to that for a flush is not the way to go.All in all, I have to add
$em->flush()
in my controller, outside my other logic related to that event to store the markings.Could we add an
entered
event to the mix ? :)Transition parameters
It would be useful to have the ability to pass parameters to transitions. In my past projects with https://github.com/yohang/Finite, parameters were a necessity sooner or later. I can't provide my exact use cases, but in the example above the
start_shipping
method could have atracking_number
parameter. I could of course set it in the controller, but then half of the transition logic will be in my listener, and half in the controller. egWith finite, I used the
OptionsResolver
in my listeners to validate the passed options. In finite, we have also added a built in resolver. (This may be a bit of overkill, especially because of the yaml configuration.)I would like to submit a PR enabling this:
Would that be okay?
One workflow, or multiple state machines?
The example could be implemented with 2 state machines. (
orderStatus
,paymentStatus
and guards to validate)In the documentation I read this:
Would you recommend using a multi state workflow if there are cyclic paths (about 4-5) in a project?
Thanks!
The text was updated successfully, but these errors were encountered: