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:auto_injection_interfaces

This is an old revision of the document!


Auto Injection Interfaces

Any VuFind plugin accessed through a standard plugin interface can implement certain “-Aware” interfaces in order to be automatically injected with dependencies. This is a convenient way to gain access to other elements of the VuFind system.

Here are the relevant interfaces:

  • \VuFind\Db\Table\DbTableAwareInterface - Get access to the VuFind\DbTablePluginManager service
  • \VuFind\I18n\Translator\TranslatorAwareInterface - Get access to the VuFind\Translator service
  • \VuFindHttp\HttpServiceAwareInterface - Get access to the VuFind\Http service
  • \Zend\Log\LoggerAwareInterface - Get access to the VuFind\Logger service
  • \Zend\ServiceManager\ServiceLocatorAwareInterface - Get access to the plugin manager that constructed the current object
  • \ZfcRbac\Service\AuthorizationServiceAwareInterface - Get access to the authorization service (for permission checks)

You can also implement a setPluginManager() method as an alternative to implementing the \Zend\ServiceManager\ServiceLocatorAwareInterface; the result is the same.

Traits

Starting with VuFind 2.4, Traits are provided which can be used in addition to interfaces to automatically implement interface-specific methods (and in some case, useful related utility methods). These Traits can help to reduce redundancy in your code:

  • \VuFind\Db\Table\DbTableAwareTrait
  • \VuFind\I18n\Translator\TranslatorAwareTrait
  • \VuFindHttp\HttpServiceAwareTrait
  • \VuFind\Log\LoggerAwareTrait
  • \Zend\ServiceManager\ServiceLocatorAwareTrait
  • \ZfcRbac\Service\AuthorizationServiceAwareInterface
development/plugins/auto_injection_interfaces.1449690318.txt.gz · Last modified: 2015/12/09 19:45 by demiankatz