Skip to content
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

Benefits of Plugin #247

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions src/pages/development/components/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,22 @@ Extensions that wish to intercept and change the behavior of a *public method* c

This interception approach reduces conflicts among extensions that change the behavior of the same class or method. Your `Plugin` class implementation changes the behavior of a class function, but it does not change the class itself. Adobe Commerce and Magento Open Source call these interceptors sequentially according to a configured sort order, so they do not conflict with one another.

## Benefits

For a module developer as you, Magento 2 Interception plugin allows:

* Forwarding any method call that is used on an object manager controlled object and taken programmatic action
* Modifying the return value of any method call that is used on an object manager controlled object
* Modifying the arguments of any method call that is used on an object manager controlled object
* Proceeding similarly when other modules are in progress of the same method in the same or predictable way.

## Limitations

Plugins can not be used on following:

* Final methods
* Final classes
* Any class that contains at least one final public method
* Non-public methods
* Class methods (such as static methods)
* `__construct` and `__destruct`
Expand Down
Loading