Function Plugins Interceptors

Function Plugins Interceptors
M1

TOTAL:
$0.00
Compatible With: Community 1.4, 1.4.1.1, 1.4.2, 1.5, 1.6, 1.6.1, 1.6.2.0, 1.7, 1.8, 1.8.1, 1.9, 1.9.1, 1.9.2, 1.9.3

Tech Specifications

Seller:
Current Version:
1.0.3
Type:
Stable Build
Updated:
29 August, 2017
Categories:
Extensions, Content & Customizations
License Type:

Overview

Use Plugins Interceptors instead of such outdated approaches as Magento® rewrites and events!

Overview

Back to top

Plugins interceptors extension is intended for Magento developers only. As developers know, there are 2 main means to change existing functionality in Magento 1, namely events and rewrites.

A plugin, or interceptor, is an XML-construction in config.xml of an extension that enables a developer to modify the behavior of class functions. This is achieved by intercepting a function call and running code before, after or around that function call. This allows a developer to substitute or extend the behavior of original methods for any blocks, helpers and models.

  • events > - a proper/recommended approach, but 'events' are not always available where they are needed.
  • rewrite > - not a better solution since there might be several extensions fighting for the same overrided class, which often leads to a conflict between extensions.
  • plugin > - a new solution we have developed for everyone and for free. Plugins interceptors, similarly to Magento 2, helps you avoid conflicts, rewrites and makes development process more flexible. This extension is going to bring Magento 1 to life. Again.

This interception approach reduces conflicts among extensions that change the behavior of the same class or method. What is it that makes these plugins work with one another without conflicts? The interceptors can be called one by one in accordance with a specified sort order.

The extension enables intercepting public and protected methods. Obviously, the final and private methods as well as final classes are not supported.

Implementation example

Plugin syntax is similar to that of both rewrite and events. Add the code below in the current module’s ModuleName/etc/config.xml:

(See image 2)

ModuleName/Model/Plugin.php file needs to be created (like Observer.php for events): 

(See image 3)

To download more examples, click on the link: SafeMage_PluginExample.zip

How it works

The extension includes a setting:

  • System > Config > Advanced > System > Plugins Interceptors

where one can see a full list of plugins and their sort order, and enable/disable all plugins.

For each class (for example, Mage_Catalog_Block_Product_List) the plugins work with, a new file of Plugged-class is being generated located in: MagentoRoot/var/cache/plugins/Mage_Catalog_Block_Product_List_Plugged.php

(See image 4)

This Plugged-class is performed autoload() and used by Magento instead of the original Mage_Catalog_Block_Product_List to call plugins upon affected methods.

With cache disabled, the file is generated anew when the target class has been addressed. But with Cache Type = Configuration enabled, the file is generated only once and then is being pulled from cache, which doesn’t drain your system’s performance, until this cache type has been refreshed (or 'Flush all cache' has been activated).

Features

  • Speeds up development process
  • Works with blocks, helpers and models
  • Runs code before, after or around that method call
  • Adds plugins to public and protected methods
  • Ability to enable/disable plugins
  • Preview listing of all plugins and their sort order
  • Does not affect Magento performance
  • Works with/without Magento cache running
  • Compatible with compilation mode

For more information about this plugin, click here.  

Should you have any remarks or suggestions about enhancing the plugin’s functionality, don’t hesitate to Contact us.

 

 

 

Release Notes

Back to top

1.0.3:

  • Compatible with CE: 1.4 1.4.1.1 1.4.2 1.5 1.6 1.6.1 1.6.2.0 1.7 1.8 1.8.1 1.9 1.9.1 1.9.2 1.9.3
  • Stability: Stable Build
  • Description:

    Initial Release

Support

Back to top
The best place to start if you need help with a specific extension is to contact the developer. All Magento developers have both a contact email and a support email listed.

Q & A

Back to top

Reviews

Back to top