Skip to content

Workflow/State Machine, guard event is triggered with the wrong transition #46381

Answered by lyrixx
netstrada-master asked this question in Q&A
Discussion options

You must be logged in to vote

Hello,

Your listener is called because after the transition complete_payment is applied, the workflow searches for new available available transitions, in order to dispatch a new event.

ref: https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/Workflow/Workflow.php#L240

You can control what events event (workflow.announce) are dispatched thanks to the configuration


about

Also, once I apply complete_payment with or without the context argument, in the Event Subscriber I still get an empty array.

This is done on purpose, to avoid any side effect. The guard must vote with the subject only, not with the context. Context is here only for additional data to be saved. So if you n…

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@netstrada-master
Comment options

@AlexBevilacqua
Comment options

Comment options

You must be logged in to vote
2 replies
@AlexBevilacqua
Comment options

@cjgordon
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by lyrixx
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants
Converted from issue

This discussion was converted from issue #46369 on May 17, 2022 14:42.