About Features Downloads Getting Started Documentation Events Support GitHub

Love VuFind®? Consider becoming a financial supporter. Your support helps build a better VuFind®!

Site Tools


Warning: This page has not been updated in over over a year and may be outdated or deprecated.
development:plugins:general_information

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
development:plugins:general_information [2015/12/09 19:46] – [Accessing Other Plugins / Services] demiankatzdevelopment:plugins:general_information [2020/03/03 20:08] (current) demiankatz
Line 1: Line 1:
 ====== General Plugin Information ====== ====== General Plugin Information ======
  
-Zend plugin is any class that is determined at runtime.+A plugin is any class that is determined at runtime.
  
-Although VuFind 2.0 provides a wide variety of plugins for a wide variety of purposes, they all follow certain basic patterns:+Although VuFind versions 2.x and later provide a wide variety of plugins for a wide variety of purposes, they all follow certain basic patterns:
  
   * Each family of plugins has a common interface and/or base class.   * Each family of plugins has a common interface and/or base class.
-  * Each family of plugins is loaded with the help of a [[vufind2:zend_framework_2.0|Zend Framework]] service locator, which in turn can be obtained from the main [[http://framework.zend.com/manual/2.0/en/modules/zend.service-manager.intro.html|Service Manager]]. +  * Each family of plugins is loaded with the help of a [[development:architecture:laminas|Laminas]] service locator, which in turn can be obtained from the main [[https://docs.laminas.dev/laminas-servicemanager/|Service Manager]]. 
-  * Each plugin-specific service locator can be configured through its own section of module.config.php inside VuFind's main module (which can be overridden and extended through a [[vufind2:customizing_vufind_2.0#modules|local custom module]]).+  * Each plugin-specific service locator can be configured through its own section of module.config.php inside VuFind's main module (which can be overridden and extended through a [[development:architecture:customizing_vufind#modules|local custom module]]).
   * Each family of plugins lives in its own namespace, but VuFind can be configured to load custom plugins from other places.   * Each family of plugins lives in its own namespace, but VuFind can be configured to load custom plugins from other places.
  
 All of the specific details for each plugin type can be found in the [[:development|VuFind 2.x Developer Manual]]. All of the specific details for each plugin type can be found in the [[:development|VuFind 2.x Developer Manual]].
  
 +:!: In some cases [[development:code_generators|code generators]] can be used to automate parts of the procedures described below.
 ===== Creating a New Plugin ===== ===== Creating a New Plugin =====
  
Line 18: Line 19:
 1.) Create a class implementing the appropriate plugin interface and/or extending the appropriate plugin base class. 1.) Create a class implementing the appropriate plugin interface and/or extending the appropriate plugin base class.
  
-2a.) If you are using a [[vufind2:customizing_vufind_2.0#modules|custom module]], put the new class in your custom module's namespace and add an entry to your module's config/module.config.php to register the new plugin in the appropriate service locator.+2a.) If you are using a [[development:architecture:customizing_vufind#modules|custom module]], put the new class in your custom module's namespace and add an entry to your module's config/module.config.php to register the new plugin in the appropriate service locator.
  
 2b.) If you are modifying core VuFind code, put the new class in the standard namespace for its plugin type, and modify the main config/module.config.php to register the new plugin. 2b.) If you are modifying core VuFind code, put the new class in the standard namespace for its plugin type, and modify the main config/module.config.php to register the new plugin.
Line 26: Line 27:
 If you want to modify or replace the functionality of an existing plugin, follow these steps: If you want to modify or replace the functionality of an existing plugin, follow these steps:
  
-1.) If you do not already have one, create a [[vufind2:customizing_vufind_2.0#modules|custom module]].+1.) If you do not already have one, create a [[development:architecture:customizing_vufind#modules|custom module]].
  
 2.) Create a new class in your custom module which replaces the core plugin.  In many cases, you will want to extend the existing plugin and override or add methods... but if you want to write a whole new class that implements the same interface, that is also possible. 2.) Create a new class in your custom module which replaces the core plugin.  In many cases, you will want to extend the existing plugin and override or add methods... but if you want to write a whole new class that implements the same interface, that is also possible.
Line 32: Line 33:
 3.) Edit your module's module.config.php so that the service locator configuration for your plugin overrides the default setting from the main VuFind configuration. 3.) Edit your module's module.config.php so that the service locator configuration for your plugin overrides the default setting from the main VuFind configuration.
  
-Starting with VuFind 2.4, you can use [[vufind2:code_generators]] to automate this process in many cases.+Starting with VuFind 2.4, you can use [[development:code_generators|code generators]] to automate this process in many cases.
  
 ===== Using a Plugin ===== ===== Using a Plugin =====
  
-Most plugins are configured through [[:config.ini]] or other VuFind user configuration files.  To configure a plugin, just use the name that you chose when you registered the plugin in the service locator.  Most plugin configurations will also support a fully-qualified class name if you prefer to bypass service locator configuration, but this is not recommended.+Most plugins are configured through [[configuration:files:config.ini]] or other VuFind user configuration files.  To configure a plugin, just use the name that you chose when you registered the plugin in the service locator.  Most plugin configurations will also support a fully-qualified class name if you prefer to bypass service locator configuration, but this is not recommended.
  
 ===== Accessing Other Plugins / Services ===== ===== Accessing Other Plugins / Services =====
  
-If you implement the [[https://github.com/zendframework/zf2/blob/master/library/Zend/ServiceManager/ServiceLocatorAwareInterface.php|\Zend\ServiceManager\ServiceLocatorAwareInterface]] in your plugin, it will be automatically injected with the appropriate service locator for its plugin type.  This means that you can load additional plugins of the same type using $this->getServiceLocator()->get($pluginName); and you can get access to the top-level Service Manager using $this->getServiceLocator()->getServiceLocator(). +If your plugin depends on other components, it is often desirable to inject dependencies into the constructor in a factory in the service manager configuration. Certain standard components can also be accessed by implementing [[development:plugins:auto_injection_interfaces|auto injection interfaces]].
- +
-If your plugin depends on other components, it is often preferable to inject dependencies into the constructor in a factory in the service manager configuration rather than overusing the ServiceLocatorAwareInterface Certain standard components can also be accessed by implementing [[development:plugins:auto_injection_interfaces|auto injection interfaces]].+
 ---- struct data ---- ---- struct data ----
 +properties.Page Owner : 
 ---- ----
  
development/plugins/general_information.1449690382.txt.gz · Last modified: 2015/12/09 19:46 by demiankatz