From a443752af7661ded43c3cf38a62313ea3c6b86c7 Mon Sep 17 00:00:00 2001 From: SAID RAJAFALLAH Date: Thu, 21 Mar 2024 00:44:32 +0000 Subject: [PATCH] Benefits of Plugin --- src/pages/development/components/plugins.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pages/development/components/plugins.md b/src/pages/development/components/plugins.md index 703d7fda6..abf17de99 100644 --- a/src/pages/development/components/plugins.md +++ b/src/pages/development/components/plugins.md @@ -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`