Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Workflow] Add EventNameTrait to compute event name strings in subscribers#54344
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
62740c8 to3fb63f1CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
lyrixx commentedMar 20, 2024
Did you see#51210? |
squrious commentedMar 20, 2024
Yes! But as event subscribers allow to register events too, shouldn't we take care of their DX too? Or maybe I could leverage the existing code for this? |
lyrixx commentedMar 20, 2024
IMHO, event listener are better thank event subscriber now. But I think we can do something for the subscriber too. I'll review it |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
derrabus commentedMar 20, 2024
No. I'd rather get rid of subscribers, tbh. From my POV, the only reason subscribers still exist, is the amount of busy work we would force upon downstream code if we removed them. Regarding DX improvements, I'd keep our efforts focused on attribute-based listeners. |
lyrixx commentedMar 20, 2024
@derrabus with SF full stack, it's easy to register listener, but without the framework, it's harder. I think it's still better to merge this PR once ready |
6ef6cb5 to194a623Comparesqurious commentedMar 20, 2024
Thanks for your feedback! I addressed your comments :) |
lyrixx left a comment
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.
Can you add a note in the CHANGELOG ?
👍🏼
2e4ecd0 tod231549Comparesqurious commentedMar 20, 2024
Done! |
lyrixx left a comment
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.
Thanks
Uh oh!
There was an error while loading.Please reload this page.
| trait EventNameTrait | ||
| { | ||
| /** | ||
| * Get event name for workflow and transition. |
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.
| *Get event name for workflowand transition. | |
| *Gets the event namefor workflowand transition. |
| } | ||
| /** | ||
| * Get event name for workflow and place. |
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.
| *Get event name for workflowand place. | |
| *Gets the event namefor workflowand place. |
0aad8af to742221fComparefabpot commentedMar 21, 2024
Thank you@squrious. |
Hello!
Using the event dispatcher, we usually use event's class name to configure the event to listen to. For workflow, we
still have to use raw strings:
Using class names is more clear about what event we use (easier to know which event to use in the listener). Even if we already have attributes to define event listeners, the event subscriber way could be improved.
Proposal
This PR adds a trait to improve DX when using workflow events in event subscribers.
For a better DX, the
EventNameTraitprovides two methods:getNameForPlaceandgetNameForTransition, so the secondargument of
::getand its PHPDoc are consistent with the event type.In event classes, it is used like:
Cheers!