Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/internal/Magento/Framework/Event/ObserverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/**
* Interface \Magento\Framework\Event\ObserverInterface
*
* @api
Copy link
Contributor

@orlangur orlangur Feb 21, 2018

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

@Vinai Vinai Feb 21, 2018

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.

*/
interface ObserverInterface
{
Expand Down