-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Workflow] fixed $context not available on GuardEvent #43996
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
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
Hey. Thank you for this PR. Could you please give me a link to where in the docs it says that |
Hello @Nyholm check on https://symfony.com/doc/current/workflow.html#using-events In Symfony 5.2, the context is accessible in all events: // in an event listener I think it is useful to have an instance of Have a nice day |
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.
Adding an additional parameter to all those methods is a breaking change and has to come with a proper deprecation layer. There's no way we can do this in a bugfix release.
In the PR that introduced this feature guard events were not changed on purpose: #37539 (comment) This looks like something that needs to be changed in the documentation instead. |
I agree with you if this changes become has a breaking change, but it is backward compatibility because it is optional just for the case if needed, so I don't see the need to deprecated anything. |
Hello @xabbuh
After read the thread you suggest, I see your point, but let me talk about my use case and why I see the need to have access to context on GuardEvent. I am working on some chatbots where the conversation state is handled by Workflow with The I hope you see my point, otherwise I am open to discuss better approach to implement this use case. Have a nice day |
No, it isn't. For example, if I had a custom implementation of
Yes, we would need to deprecate implementations of Your use-case might be valid, but this change is by our definition a new feature. I'm moving this to the 6.1 milestone which is our next feature release. |
Awesome. Now it is correctly labeled as a new feature in 6.1. May I ask @lyrixx to elaborate on this comment where you say you are agains guard events having context? |
Hi @derrabus You have all the right, I have done the requested changes. Thanks for your support |
Hi @lyrixx I would like to listen your opinion too about why not Thanks in advance |
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 have done the requested changes.
Well, no. You have added a new method to an interface which is also a breaking change. Also, the original problem is still there for all other methods of the interface.
But let's first discuss this feature first. I'm certain someone will help you building the deprecation layer once we've come to a decision about this feature.
Hello, I always refused to add the context to the apply method because the context (must) contains only "contextual" content (date, user, for example) To me, the decision to accept of deny a transition should only occurs against the subject that pass into the workflow. If you want to vote on somethings else, it should be on the subject. BTW, this value does't have to be persisted. |
Thanks, @lyrixx, for your reply I understand your argument, it makes sense from your point of view, but the end developer using workflow must have the choice to decide what is needed as contextual based on his needs. Workflow is an excellent component, but in my opinion must be consistent with the docs about the context is available to all events, not a few of them only, because it makes confuse use it. Take this only has a constructive opinion, I am open to contribute and help to improve this component. |
Sure, the doc must be fixed :) Would you mind to submit a PR? That would be lovely. Thanks |
Already done |
For Workflow component, the $context should be available for all events as described on official doc, but GuardEvent don't receive the $context when is instantiated, the context is useful in many ways, so grant access to it on GuardEvent allow developers to get custom payload on workflow guard event listeners