Share on Google+Share on Google+


Plugins are heavily used in ZF. With plugins we can achieve extensibility and customization of the framework. In the current tutorial we will discuss about the plugin in ZF, what is actually a plugin in ZF, use of plugins in ZF.

Plugins in ZF:

Plugins are heavily used in ZF. With plugins we can achieve extensibility and customization of the framework.

Plugins in ZF :

  • Plugins are classes:
  • Related plugins share a common class prefix.
  • Plugin names are case sensitive.
  • Any name after the common prefix will be considered as the plugin name.

Components use Zend_Loader_PluginLoader to make use of plugins. Then the components will call the PluginLoader's load() method and pass the plugin's short name with it.  The PluginLoader will then query each prefix path to see whether the class matching the short name exists. LIFO (Last In First Out) data structure is used to match those prefix paths.

The concept of prefix paths and overriding existing plugins  helps us to understand  many components ZF. Use of plugins are :

  1. Zend_Application: resources.

  2. Zend_Feed_Reader: plugins.

  3. Zend_View: view helpers

  4. Zend_Controller_Action: action helpers.

  5. Zend_Form: elements, filters, validators, and decorators. .

Let's consider one example: Zend_View_Helper_FormButton.  This view helper accepts three arguments, first is element name (element's DOM identifier), second is the value (button label), and the last one is optional array of attributes. After getting these arguments this helper generates the form input element in HTML.

Suppose you want the helper to  generate a  HTML button element; not a DOM identifier, instead of using the value for a CSS class selector; and  you are not interestest in handling arbitrary attributes. We can get this by more than one ways. In both the cases, we would create view helper class that will implement the behavior which is actually needed ; the difference lies  in how we would name and invoke them.



Posted on: April 28, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null