-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Add ObserverInterface to the api #13759
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
Add ObserverInterface to the api #13759
Conversation
|
Hi @ihor-sviziev, thank you for the review. |
| /** | ||
| * Interface \Magento\Framework\Event\ObserverInterface | ||
| * | ||
| * @api |
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.
It would be good to add a note also that observers creation should be avoided whenever possible in favor of plugins-interceptors.
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.
Why? There are plenty of places where an event observer is better suited than a plugin.
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.
Mainly because "There can be only one" intention.
The only valid place for event dispatching I heard of are some controllers in MSI project.
All other places in current code which seem better suited by observers is just unrefactored legacy which is doing to much. In code written with plugins in mind there is no need in event dispatching at all.
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.
Lol, there is soooo much legacy code that will never be rewritten because it would break so many extensions. Maybe in Magento 3. But for Magento 2 I don't consider that realistic.
Description
Creating an observer that uses ObserverInterface should not trigger a patch level dependency on magento/framework.
Fixed Issues (if relevant)
N/A
Contribution checklist