Skip to content

Conversation

@fooman
Copy link
Contributor

@fooman fooman commented Feb 20, 2018

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

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, thank you for the review.
MAGETWO-88146 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

@fooman thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

/**
* 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.

@magento-engcom-team magento-engcom-team merged commit 187a430 into magento:2.2-develop Feb 22, 2018
@fooman fooman deleted the add-api-to-observer-interface branch February 22, 2018 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants